#include <linux/sched.h>
#include <linux/smp_lock.h>
#include <linux/module.h>
#include <asm/uaccess.h>
#include <rsbac/types.h>
#include <rsbac/error.h>
#include <rsbac/helpers.h>
#include <rsbac/getname.h>
#include <rsbac/debug.h>
#include <rsbac/adf.h>
#include <rsbac/aci_data_structures.h>
#include <rsbac/proc_fs.h>
#include <rsbac/rkmem.h>
#include <rsbac/lists.h>
#include <rsbac/gen_lists.h>
Go to the source code of this file.
#define lol_touch | ( | x | ) |
Definition at line 2959 of file gen_lists.c.
Referenced by rsbac_ta_list_lol_add_ttl(), rsbac_ta_list_lol_remove(), rsbac_ta_list_lol_subadd_ttl(), rsbac_ta_list_lol_subremove(), rsbac_ta_list_lol_subremove_all(), and rsbac_ta_list_lol_subremove_count().
#define touch | ( | x | ) |
Definition at line 2957 of file gen_lists.c.
Referenced by rsbac_ta_list_add_ttl(), and rsbac_ta_list_remove().
static struct rsbac_list_item_t* add_item | ( | struct rsbac_list_reg_item_t * | list, | |
rsbac_time_t | max_age, | |||
void * | desc, | |||
void * | data | |||
) | [static] |
Definition at line 1228 of file gen_lists.c.
References rsbac_list_reg_item_t::compare, rsbac_list_hashed_t::count, rsbac_list_hashed_t::curr, rsbac_list_info_t::data_size, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::device, rsbac_list_reg_item_t::flags, rsbac_list_reg_item_t::hash_function, rsbac_list_reg_item_t::hashed, rsbac_list_hashed_t::head, rsbac_list_reg_item_t::info, insert_item_compare(), insert_item_memcmp(), rsbac_list_reg_item_t::max_items_per_hash, rsbac_list_reg_item_t::name, rsbac_list_reg_item_t::nr_hashes, NULL, rsbac_kfree(), rsbac_kmalloc(), RSBAC_LIST_NO_MAX_WARN, rsbac_printk(), and rsbac_list_hashed_t::tail.
01231 { 01232 struct rsbac_list_item_t *new_item_p = NULL; 01233 u_int hash = 0; 01234 01235 if (!list || !desc) 01236 return NULL; 01237 01238 if (!list || !desc) 01239 return NULL; 01240 if (list->info.data_size && !data) 01241 return NULL; 01242 /* item desc and data are behind official struct */ 01243 if (! 01244 (new_item_p = 01245 rsbac_kmalloc(sizeof(*new_item_p) + list->info.desc_size + 01246 list->info.data_size))) 01247 return (NULL); 01248 new_item_p->max_age = max_age; 01249 /* item desc is behind official struct */ 01250 memcpy(&new_item_p[1], desc, list->info.desc_size); 01251 /* item data is behind official struct and desc */ 01252 /* data might be empty! */ 01253 if (data && list->info.data_size) 01254 memcpy(((__u8 *) new_item_p) + sizeof(*new_item_p) + 01255 list->info.desc_size, data, list->info.data_size); 01256 01257 if(list->hash_function) 01258 hash = list->hash_function(desc, list->nr_hashes); 01259 if (!list->hashed[hash].head) { 01260 list->hashed[hash].head = new_item_p; 01261 list->hashed[hash].tail = new_item_p; 01262 list->hashed[hash].curr = new_item_p; 01263 list->hashed[hash].count = 1; 01264 new_item_p->prev = NULL; 01265 new_item_p->next = NULL; 01266 return new_item_p; 01267 } 01268 if(list->hashed[hash].count >= list->max_items_per_hash) { 01269 rsbac_kfree(new_item_p); 01270 if (!(list->flags & RSBAC_LIST_NO_MAX_WARN)) 01271 rsbac_printk(KERN_WARNING "add_item(): cannot add item to list %s, hash %u on device %02u:%02u, would be more than %u items!\n", 01272 list->name, 01273 hash, 01274 RSBAC_MAJOR(list->device), 01275 RSBAC_MINOR(list->device), 01276 list->max_items_per_hash); 01277 return NULL; 01278 } 01279 if (list->compare) 01280 return insert_item_compare(list, desc, new_item_p); 01281 else 01282 return insert_item_memcmp(list, desc, new_item_p); 01283 }
static struct rsbac_list_lol_item_t* add_lol_item | ( | struct rsbac_list_lol_reg_item_t * | list, | |
rsbac_time_t | max_age, | |||
void * | desc, | |||
void * | data | |||
) | [static] |
Definition at line 1902 of file gen_lists.c.
References rsbac_list_lol_reg_item_t::compare, rsbac_list_lol_hashed_t::count, rsbac_list_lol_hashed_t::curr, rsbac_list_lol_info_t::data_size, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::device, rsbac_list_lol_reg_item_t::flags, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_hashed_t::head, rsbac_list_lol_reg_item_t::info, insert_lol_item_compare(), insert_lol_item_memcmp(), rsbac_list_lol_reg_item_t::max_items_per_hash, rsbac_list_lol_reg_item_t::name, rsbac_list_lol_reg_item_t::nr_hashes, NULL, rsbac_kfree(), rsbac_kmalloc(), RSBAC_LIST_NO_MAX_WARN, rsbac_printk(), and rsbac_list_lol_hashed_t::tail.
Referenced by do_read_lol_list(), rsbac_ta_list_lol_add_ttl(), and rsbac_ta_list_lol_subadd_ttl().
01907 { 01908 struct rsbac_list_lol_item_t *new_item_p = NULL; 01909 u_int hash = 0; 01910 01911 if (!list || !desc) 01912 return NULL; 01913 if (list->info.data_size && !data) 01914 return NULL; 01915 /* item desc and data are behind official struct */ 01916 if (! 01917 (new_item_p = 01918 rsbac_kmalloc(sizeof(*new_item_p) + list->info.desc_size + 01919 list->info.data_size))) 01920 return (NULL); 01921 /* Init sublist */ 01922 new_item_p->head = NULL; 01923 new_item_p->tail = NULL; 01924 new_item_p->curr = NULL; 01925 new_item_p->count = 0; 01926 new_item_p->max_age = max_age; 01927 /* item desc is behind official struct */ 01928 memcpy(&new_item_p[1], desc, list->info.desc_size); 01929 /* item data is behind official struct and desc */ 01930 /* data might be empty! */ 01931 if (data && list->info.data_size) 01932 memcpy(((__u8 *) new_item_p) + sizeof(*new_item_p) + 01933 list->info.desc_size, data, list->info.data_size); 01934 01935 if(list->hash_function) 01936 hash = list->hash_function(desc, list->nr_hashes); 01937 if (!list->hashed[hash].head) { 01938 list->hashed[hash].head = new_item_p; 01939 list->hashed[hash].tail = new_item_p; 01940 list->hashed[hash].curr = new_item_p; 01941 list->hashed[hash].count = 1; 01942 new_item_p->prev = NULL; 01943 new_item_p->next = NULL; 01944 return (new_item_p); 01945 } 01946 if (list->hashed[hash].count >= list->max_items_per_hash) { 01947 rsbac_kfree(new_item_p); 01948 if (!(list->flags & RSBAC_LIST_NO_MAX_WARN)) 01949 rsbac_printk(KERN_WARNING "add_lol_item(): cannot add item to list %s, hash %u on device %02u:%02u, would be more than %u items!\n", 01950 list->name, 01951 hash, 01952 RSBAC_MAJOR(list->device), 01953 RSBAC_MINOR(list->device), 01954 list->max_items_per_hash); 01955 return NULL; 01956 } 01957 if (list->compare) 01958 return insert_lol_item_compare(list, desc, new_item_p); 01959 else 01960 return insert_lol_item_memcmp(list, desc, new_item_p); 01961 }
static struct rsbac_list_lol_reg_item_t* add_lol_reg | ( | struct rsbac_list_lol_reg_item_t * | new_item_p | ) | [static] |
Definition at line 2382 of file gen_lists.c.
References rsbac_list_lol_reg_head_t::count, rsbac_list_lol_reg_head_t::curr, rsbac_list_lol_reg_head_t::head, lol_reg_head, rsbac_list_lol_reg_item_t::next, NULL, rsbac_list_lol_reg_item_t::prev, and rsbac_list_lol_reg_head_t::tail.
Referenced by rsbac_list_lol_register_hashed().
02385 { 02386 if (!lol_reg_head.head) { 02387 lol_reg_head.head = new_item_p; 02388 lol_reg_head.tail = new_item_p; 02389 lol_reg_head.curr = new_item_p; 02390 lol_reg_head.count = 1; 02391 new_item_p->prev = NULL; 02392 new_item_p->next = NULL; 02393 } else { 02394 new_item_p->prev = lol_reg_head.tail; 02395 new_item_p->next = NULL; 02396 lol_reg_head.tail->next = new_item_p; 02397 lol_reg_head.tail = new_item_p; 02398 lol_reg_head.curr = new_item_p; 02399 lol_reg_head.count++; 02400 }; 02401 return (new_item_p); 02402 }
static struct rsbac_list_item_t* add_lol_subitem | ( | struct rsbac_list_lol_reg_item_t * | list, | |
struct rsbac_list_lol_item_t * | sublist, | |||
rsbac_time_t | max_age, | |||
void * | subdesc, | |||
void * | subdata | |||
) | [static] |
Definition at line 1722 of file gen_lists.c.
References rsbac_list_lol_item_t::count, rsbac_list_lol_item_t::curr, rsbac_list_lol_reg_item_t::device, rsbac_list_lol_reg_item_t::flags, rsbac_list_lol_item_t::head, rsbac_list_lol_reg_item_t::info, insert_lol_subitem_compare(), insert_lol_subitem_memcmp(), rsbac_list_lol_reg_item_t::max_subitems, rsbac_list_lol_reg_item_t::name, NULL, rsbac_kfree(), rsbac_kmalloc(), RSBAC_LIST_NO_MAX_WARN, rsbac_printk(), rsbac_list_lol_reg_item_t::subcompare, rsbac_list_lol_info_t::subdata_size, rsbac_list_lol_info_t::subdesc_size, and rsbac_list_lol_item_t::tail.
Referenced by do_read_lol_list(), and rsbac_ta_list_lol_subadd_ttl().
01731 { 01732 struct rsbac_list_item_t *new_item_p = NULL; 01733 01734 if (!list || !sublist || !subdesc) 01735 return NULL; 01736 if (list->info.subdata_size && !subdata) 01737 return NULL; 01738 /* item desc and data are behind official struct */ 01739 if (! 01740 (new_item_p = 01741 rsbac_kmalloc(sizeof(*new_item_p) + list->info.subdesc_size + 01742 list->info.subdata_size))) 01743 return (NULL); 01744 new_item_p->max_age = max_age; 01745 /* item desc is behind official struct */ 01746 memcpy(&new_item_p[1], subdesc, list->info.subdesc_size); 01747 /* item data is behind official struct and desc */ 01748 /* subdata might be empty! */ 01749 if (subdata && list->info.subdata_size) 01750 memcpy(((__u8 *) new_item_p) + sizeof(*new_item_p) + 01751 list->info.subdesc_size, subdata, 01752 list->info.subdata_size); 01753 01754 /* Sublist was empty */ 01755 if (!sublist->head) { 01756 sublist->head = new_item_p; 01757 sublist->tail = new_item_p; 01758 sublist->curr = new_item_p; 01759 sublist->count = 1; 01760 new_item_p->prev = NULL; 01761 new_item_p->next = NULL; 01762 return (new_item_p); 01763 } 01764 if (sublist->count >= list->max_subitems) { 01765 rsbac_kfree(new_item_p); 01766 if (!(list->flags & RSBAC_LIST_NO_MAX_WARN)) 01767 rsbac_printk(KERN_WARNING "add_lol_subitem(): cannot add subitem to sublist of %s on device %02u:%02u, would be more than %u subitems!\n", 01768 list->name, 01769 RSBAC_MAJOR(list->device), 01770 RSBAC_MINOR(list->device), 01771 list->max_subitems); 01772 return NULL; 01773 } 01774 if (list->subcompare) 01775 return insert_lol_subitem_compare(list, sublist, subdesc, 01776 new_item_p); 01777 else 01778 return insert_lol_subitem_memcmp(list, sublist, subdesc, 01779 new_item_p); 01780 }
static struct rsbac_list_reg_item_t* add_reg | ( | struct rsbac_list_reg_item_t * | new_item_p | ) | [static] |
Definition at line 2250 of file gen_lists.c.
References rsbac_list_reg_head_t::count, rsbac_list_reg_head_t::curr, rsbac_list_reg_head_t::head, rsbac_list_reg_item_t::next, NULL, rsbac_list_reg_item_t::prev, reg_head, and rsbac_list_reg_head_t::tail.
Referenced by rsbac_list_register_hashed().
02252 { 02253 if (!reg_head.head) { 02254 reg_head.head = new_item_p; 02255 reg_head.tail = new_item_p; 02256 reg_head.curr = new_item_p; 02257 reg_head.count = 1; 02258 new_item_p->prev = NULL; 02259 new_item_p->next = NULL; 02260 } else { 02261 new_item_p->prev = reg_head.tail; 02262 new_item_p->next = NULL; 02263 reg_head.tail->next = new_item_p; 02264 reg_head.tail = new_item_p; 02265 reg_head.curr = new_item_p; 02266 reg_head.count++; 02267 } 02268 return (new_item_p); 02269 }
int check_buffer | ( | struct rsbac_list_buffer_t ** | buffer_pp, | |
u_int | size | |||
) |
Definition at line 3757 of file gen_lists.c.
References rsbac_list_buffer_t::len, rsbac_list_buffer_t::next, NULL, RSBAC_ENOMEM, rsbac_kmalloc(), RSBAC_LIST_BUFFER_DATA_SIZE, RSBAC_LIST_BUFFER_SIZE, and rsbac_pr_debug.
Referenced by fill_buffer(), and fill_lol_buffer().
03758 { 03759 if((*buffer_pp)->len + size <= RSBAC_LIST_BUFFER_DATA_SIZE) 03760 return 0; 03761 else { 03762 struct rsbac_list_buffer_t * new_buffer; 03763 03764 new_buffer = rsbac_kmalloc(RSBAC_LIST_BUFFER_SIZE); 03765 if(!new_buffer) 03766 return -RSBAC_ENOMEM; 03767 rsbac_pr_debug(write, "Added a buffer\n"); 03768 new_buffer->next = NULL; 03769 new_buffer->len = 0; 03770 (*buffer_pp)->next = new_buffer; 03771 *buffer_pp = new_buffer; 03772 return 0; 03773 } 03774 }
static void clear_lol_reg | ( | struct rsbac_list_lol_reg_item_t * | item_p | ) | [static] |
Definition at line 2899 of file gen_lists.c.
References rsbac_list_lol_reg_item_t::def_data, rsbac_list_lol_reg_item_t::def_subdata, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_reg_item_t::nr_hashes, remove_all_lol_items(), and rsbac_kfree().
Referenced by remove_lol_reg(), and rsbac_list_lol_register_hashed().
02900 { 02901 int i; 02902 02903 if (item_p) { 02904 /* now we can remove the item from memory */ 02905 for (i=0; i<item_p->nr_hashes; i++) { 02906 remove_all_lol_items(item_p, i); 02907 #ifdef CONFIG_RSBAC_LIST_TRANS 02908 if(item_p->hashed[i].ta_copied) 02909 ta_remove_all_lol_items(item_p, i); 02910 #endif 02911 } 02912 if (item_p->def_data) 02913 rsbac_kfree(item_p->def_data); 02914 if (item_p->def_subdata) 02915 rsbac_kfree(item_p->def_subdata); 02916 rsbac_kfree(item_p->hashed); 02917 rsbac_kfree(item_p); 02918 } 02919 }
static void clear_reg | ( | struct rsbac_list_reg_item_t * | item_p | ) | [static] |
Definition at line 2842 of file gen_lists.c.
References rsbac_list_reg_item_t::def_data, rsbac_list_reg_item_t::hashed, rsbac_list_reg_item_t::nr_hashes, remove_all_items(), and rsbac_kfree().
Referenced by remove_reg(), and rsbac_list_register_hashed().
02843 { 02844 int i; 02845 02846 if (item_p) { 02847 /* now we can remove the item from memory */ 02848 for (i=0; i<item_p->nr_hashes; i++) { 02849 remove_all_items(item_p, i); 02850 #ifdef CONFIG_RSBAC_LIST_TRANS 02851 if(item_p->hashed[i].ta_copied) 02852 ta_remove_all_items(item_p, i); 02853 #endif 02854 } 02855 if (item_p->def_data) 02856 rsbac_kfree(item_p->def_data); 02857 rsbac_kfree(item_p->hashed); 02858 rsbac_kfree(item_p); 02859 } 02860 }
static struct rsbac_list_lol_reg_item_t* create_lol_reg | ( | struct rsbac_list_lol_info_t * | info_p, | |
u_int | flags, | |||
rsbac_list_compare_function_t * | compare, | |||
rsbac_list_compare_function_t * | subcompare, | |||
rsbac_list_get_conv_t * | get_conv, | |||
rsbac_list_get_conv_t * | get_subconv, | |||
void * | def_data, | |||
void * | def_subdata, | |||
char * | name, | |||
kdev_t | device, | |||
u_int | nr_hashes, | |||
rsbac_list_hash_function_t | hash_function, | |||
char * | old_name_base | |||
) | [inline, static] |
Definition at line 2272 of file gen_lists.c.
References rsbac_list_lol_info_t::data_size, FALSE, NULL, rsbac_kfree(), rsbac_kmalloc(), RSBAC_LIST_DEF_DATA, RSBAC_LIST_DEF_SUBDATA, RSBAC_LIST_MAX_FILENAME, RSBAC_LIST_MAX_NR_ITEMS, RSBAC_LIST_MAX_NR_ITEMS_LIMIT, RSBAC_LIST_MAX_NR_SUBITEMS, RSBAC_LIST_NO_MAX, RSBAC_LIST_NO_WRITE, RSBAC_LIST_NONAME, rsbac_list_lol_info_t::subdata_size, and TRUE.
Referenced by rsbac_list_lol_register_hashed().
02286 { 02287 struct rsbac_list_lol_reg_item_t *new_item_p = NULL; 02288 int i; 02289 02290 if (!(new_item_p = rsbac_kmalloc(sizeof(*new_item_p)))) 02291 return (NULL); 02292 if (!(new_item_p->hashed = rsbac_kmalloc(nr_hashes*sizeof(struct rsbac_list_lol_hashed_t)))) { 02293 rsbac_kfree(new_item_p); 02294 return (NULL); 02295 } 02296 new_item_p->info = *info_p; 02297 if (info_p->data_size && !def_data) 02298 flags &= ~RSBAC_LIST_DEF_DATA; 02299 if (!def_subdata) 02300 flags &= ~RSBAC_LIST_DEF_SUBDATA; 02301 new_item_p->flags = flags; 02302 new_item_p->compare = compare; 02303 new_item_p->subcompare = subcompare; 02304 new_item_p->get_conv = get_conv; 02305 new_item_p->get_subconv = get_subconv; 02306 if ((flags & RSBAC_LIST_DEF_DATA) 02307 && (info_p->data_size) 02308 ) { 02309 new_item_p->def_data = rsbac_kmalloc(info_p->data_size); 02310 if (new_item_p->def_data) 02311 memcpy(new_item_p->def_data, def_data, 02312 info_p->data_size); 02313 else { 02314 rsbac_kfree(new_item_p->hashed); 02315 rsbac_kfree(new_item_p); 02316 return NULL; 02317 } 02318 } else 02319 new_item_p->def_data = NULL; 02320 if (flags & RSBAC_LIST_DEF_SUBDATA) { 02321 new_item_p->def_subdata = 02322 rsbac_kmalloc(info_p->subdata_size); 02323 if (new_item_p->def_subdata) 02324 memcpy(new_item_p->def_subdata, def_subdata, 02325 info_p->subdata_size); 02326 else { 02327 if (new_item_p->def_data) 02328 rsbac_kfree(new_item_p->def_data); 02329 rsbac_kfree(new_item_p->hashed); 02330 rsbac_kfree(new_item_p); 02331 return NULL; 02332 } 02333 } else 02334 new_item_p->def_subdata = NULL; 02335 if (name) { 02336 strncpy(new_item_p->name, name, RSBAC_LIST_MAX_FILENAME); 02337 new_item_p->name[RSBAC_LIST_MAX_FILENAME] = 0; 02338 } else { 02339 strcpy(new_item_p->name, RSBAC_LIST_NONAME); 02340 } 02341 new_item_p->nr_hashes = nr_hashes; 02342 if (flags & RSBAC_LIST_NO_MAX) { 02343 new_item_p->max_items_per_hash = RSBAC_LIST_MAX_NR_ITEMS_LIMIT; 02344 new_item_p->max_subitems = RSBAC_LIST_MAX_NR_ITEMS_LIMIT; 02345 } else { 02346 new_item_p->max_items_per_hash = RSBAC_LIST_MAX_NR_ITEMS; 02347 new_item_p->max_subitems = RSBAC_LIST_MAX_NR_SUBITEMS; 02348 } 02349 new_item_p->hash_function = hash_function; 02350 if (old_name_base) { 02351 strncpy(new_item_p->old_name_base, old_name_base, RSBAC_LIST_MAX_FILENAME); 02352 new_item_p->old_name_base[RSBAC_LIST_MAX_FILENAME] = 0; 02353 } else 02354 new_item_p->old_name_base[0] = 0; 02355 new_item_p->device = device; 02356 new_item_p->lock = RW_LOCK_UNLOCKED; 02357 for(i=0; i<nr_hashes; i++) { 02358 new_item_p->hashed[i].head = NULL; 02359 new_item_p->hashed[i].tail = NULL; 02360 new_item_p->hashed[i].curr = NULL; 02361 new_item_p->hashed[i].count = 0; 02362 #ifdef CONFIG_RSBAC_LIST_TRANS 02363 new_item_p->hashed[i].ta_copied = 0; 02364 new_item_p->hashed[i].ta_head = NULL; 02365 new_item_p->hashed[i].ta_tail = NULL; 02366 new_item_p->hashed[i].ta_curr = NULL; 02367 new_item_p->hashed[i].ta_count = 0; 02368 #endif 02369 } 02370 new_item_p->dirty = FALSE; 02371 if (flags & RSBAC_LIST_NO_WRITE) 02372 new_item_p->no_write = TRUE; 02373 else 02374 new_item_p->no_write = FALSE; 02375 new_item_p->lastchange.sec = 0; 02376 new_item_p->lastchange.nsec = 0; 02377 new_item_p->self = new_item_p; 02378 return (new_item_p); 02379 }
static struct rsbac_list_reg_item_t* create_reg | ( | struct rsbac_list_info_t * | info_p, | |
u_int | flags, | |||
rsbac_list_compare_function_t * | compare, | |||
rsbac_list_get_conv_t * | get_conv, | |||
void * | def_data, | |||
char * | name, | |||
kdev_t | device, | |||
u_int | nr_hashes, | |||
rsbac_list_hash_function_t | hash_function, | |||
char * | old_name_base | |||
) | [inline, static] |
Definition at line 2166 of file gen_lists.c.
References rsbac_list_info_t::data_size, FALSE, NULL, rsbac_kfree(), rsbac_kmalloc(), RSBAC_LIST_DEF_DATA, RSBAC_LIST_MAX_FILENAME, RSBAC_LIST_MAX_NR_ITEMS, RSBAC_LIST_MAX_NR_ITEMS_LIMIT, RSBAC_LIST_NO_MAX, RSBAC_LIST_NO_WRITE, RSBAC_LIST_NONAME, and TRUE.
Referenced by rsbac_list_register_hashed().
02177 { 02178 struct rsbac_list_reg_item_t *new_item_p = NULL; 02179 int i; 02180 02181 if (!(new_item_p = rsbac_kmalloc(sizeof(*new_item_p)))) 02182 return (NULL); 02183 if (!(new_item_p->hashed = rsbac_kmalloc(nr_hashes*sizeof(struct rsbac_list_hashed_t)))) { 02184 rsbac_kfree(new_item_p); 02185 return (NULL); 02186 } 02187 new_item_p->info = *info_p; 02188 if (!def_data) 02189 flags &= ~RSBAC_LIST_DEF_DATA; 02190 new_item_p->flags = flags; 02191 new_item_p->compare = compare; 02192 new_item_p->get_conv = get_conv; 02193 if (flags & RSBAC_LIST_DEF_DATA) { 02194 new_item_p->def_data = rsbac_kmalloc(info_p->data_size); 02195 if (new_item_p->def_data) 02196 memcpy(new_item_p->def_data, def_data, 02197 info_p->data_size); 02198 else { 02199 rsbac_kfree(new_item_p->hashed); 02200 rsbac_kfree(new_item_p); 02201 return NULL; 02202 } 02203 } else 02204 new_item_p->def_data = NULL; 02205 if (name) { 02206 strncpy(new_item_p->name, name, RSBAC_LIST_MAX_FILENAME); 02207 new_item_p->name[RSBAC_LIST_MAX_FILENAME] = 0; 02208 } else { 02209 strcpy(new_item_p->name, RSBAC_LIST_NONAME); 02210 } 02211 new_item_p->nr_hashes = nr_hashes; 02212 if (flags & RSBAC_LIST_NO_MAX) 02213 new_item_p->max_items_per_hash = RSBAC_LIST_MAX_NR_ITEMS_LIMIT; 02214 else 02215 new_item_p->max_items_per_hash = RSBAC_LIST_MAX_NR_ITEMS; 02216 new_item_p->hash_function = hash_function; 02217 if (old_name_base) { 02218 strncpy(new_item_p->old_name_base, old_name_base, RSBAC_LIST_MAX_FILENAME); 02219 new_item_p->old_name_base[RSBAC_LIST_MAX_FILENAME] = 0; 02220 } else { 02221 new_item_p->old_name_base[0] = 0; 02222 } 02223 new_item_p->device = device; 02224 new_item_p->lock = RW_LOCK_UNLOCKED; 02225 for(i=0; i<nr_hashes; i++) { 02226 new_item_p->hashed[i].head = NULL; 02227 new_item_p->hashed[i].tail = NULL; 02228 new_item_p->hashed[i].curr = NULL; 02229 new_item_p->hashed[i].count = 0; 02230 #ifdef CONFIG_RSBAC_LIST_TRANS 02231 new_item_p->hashed[i].ta_copied = 0; 02232 new_item_p->hashed[i].ta_head = NULL; 02233 new_item_p->hashed[i].ta_tail = NULL; 02234 new_item_p->hashed[i].ta_curr = NULL; 02235 new_item_p->hashed[i].ta_count = 0; 02236 #endif 02237 } 02238 new_item_p->dirty = FALSE; 02239 if (flags & RSBAC_LIST_NO_WRITE) 02240 new_item_p->no_write = TRUE; 02241 else 02242 new_item_p->no_write = FALSE; 02243 new_item_p->lastchange.sec = 0; 02244 new_item_p->lastchange.nsec = 0; 02245 new_item_p->self = new_item_p; 02246 return new_item_p; 02247 }
static int do_lol_rehash | ( | struct rsbac_list_lol_reg_item_t * | list, | |
u_int | new_nr | |||
) | [static] |
Definition at line 10481 of file gen_lists.c.
References rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EBUSY, RSBAC_ENOMEM, and rsbac_kmalloc().
10482 { 10483 struct rsbac_list_lol_hashed_t * old_hashed; 10484 int i; 10485 struct rsbac_list_lol_item_t *item_p; 10486 struct rsbac_list_lol_item_t *next_item_p; 10487 u_int new_hash; 10488 u_int old_nr; 10489 10490 #ifdef CONFIG_RSBAC_LIST_TRANS 10491 for(i=0; i<list->nr_hashes; i++) 10492 if(list->hashed[i].ta_copied) 10493 return -RSBAC_EBUSY; 10494 #endif 10495 old_hashed = list->hashed; 10496 list->hashed = rsbac_kmalloc(new_nr*sizeof(struct rsbac_list_lol_hashed_t)); 10497 if(!list->hashed) { 10498 list->hashed = old_hashed; 10499 return -RSBAC_ENOMEM; 10500 } 10501 memset(list->hashed, 0, new_nr*sizeof(struct rsbac_list_lol_hashed_t)); 10502 old_nr = list->nr_hashes; 10503 list->nr_hashes = new_nr; 10504 for(i=0; i<old_nr; i++) { 10505 item_p = old_hashed[i].head; 10506 while(item_p) { 10507 next_item_p = item_p->next; 10508 new_hash = list->hash_function(&item_p[1], new_nr); 10509 if (!list->hashed[new_hash].head) { 10510 list->hashed[new_hash].head = item_p; 10511 list->hashed[new_hash].tail = item_p; 10512 list->hashed[new_hash].curr = item_p; 10513 list->hashed[new_hash].count = 1; 10514 item_p->prev = NULL; 10515 item_p->next = NULL; 10516 } else 10517 if (list->compare) 10518 insert_lol_item_compare(list, &item_p[1], item_p); 10519 else 10520 insert_lol_item_memcmp(list, &item_p[1], item_p); 10521 item_p = next_item_p; 10522 } 10523 } 10524 return 0; 10525 }
static int do_read_list | ( | struct rsbac_list_reg_item_t * | list, | |
char * | name | |||
) | [static] |
Definition at line 2965 of file gen_lists.c.
References add_item(), rsbac_list_info_t::data_size, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::device, FALSE, rsbac_list_reg_item_t::flags, rsbac_list_reg_item_t::get_conv, rsbac_list_reg_item_t::info, rsbac_list_info_t::key, rsbac_list_reg_item_t::lock, NULL, RSBAC_EINVALIDLIST, RSBAC_EINVALIDVERSION, RSBAC_ENOMEM, RSBAC_EREADFAILED, rsbac_kfree(), rsbac_kmalloc(), RSBAC_LIST_DISK_OLD_VERSION, RSBAC_LIST_DISK_VERSION, RSBAC_LIST_IGNORE_OLD, RSBAC_LIST_IGNORE_UNSUPP_VERSION, rsbac_pr_debug, rsbac_printk(), rsbac_read_close(), rsbac_read_open(), TRUE, and rsbac_list_info_t::version.
Referenced by read_list().
02966 { 02967 struct file *file_p; 02968 int err = 0; 02969 int tmperr; 02970 int converr; 02971 rsbac_version_t list_version; 02972 u_long read_count = 0; 02973 u_long flags; 02974 char *old_buf; 02975 char *new_buf; 02976 char *old_data; 02977 char *new_data; 02978 struct rsbac_list_info_t *list_info_p; 02979 rsbac_list_count_t list_count; 02980 rsbac_time_t timestamp; 02981 struct rsbac_nanotime_t lastchange; 02982 rsbac_time_t max_age = 0; 02983 rsbac_list_conv_function_t *conv = NULL; 02984 rsbac_boolean_t timeout = FALSE; 02985 mm_segment_t oldfs; 02986 02987 list_info_p = rsbac_kmalloc(sizeof(*list_info_p)); 02988 if (!list_info_p) 02989 return -RSBAC_ENOMEM; 02990 file_p = rsbac_kmalloc(sizeof(*file_p)); 02991 if (!file_p) { 02992 rsbac_kfree(list_info_p); 02993 return -RSBAC_ENOMEM; 02994 } 02995 /* open file */ 02996 if ((err = rsbac_read_open(name, file_p, list->device))) { 02997 rsbac_kfree(list_info_p); 02998 rsbac_kfree(file_p); 02999 return (err); 03000 } 03001 03002 /* OK, now we can start reading */ 03003 /* There is a read function for this file, so check info and read as 03004 * many items as possible. A positive return value means a read success, 03005 * 0 end of file and a negative value an error. */ 03006 03007 /* Set current user space to kernel space, because read() writes */ 03008 /* to user space */ 03009 oldfs = get_fs(); 03010 set_fs(KERNEL_DS); 03011 03012 /* check gen-list on-disk version */ 03013 tmperr = file_p->f_op->read(file_p, 03014 (__u8 *) & list_version, 03015 sizeof(list_version), &file_p->f_pos); 03016 set_fs(oldfs); 03017 /* error? */ 03018 if (tmperr < sizeof(list_version)) { 03019 rsbac_printk(KERN_WARNING "do_read_list(): read error from file!\n"); 03020 err = -RSBAC_EREADFAILED; 03021 goto end_read; 03022 } 03023 /* if wrong list on-disk version, fail */ 03024 switch (list_version) { 03025 case RSBAC_LIST_DISK_VERSION: 03026 case RSBAC_LIST_DISK_OLD_VERSION: 03027 break; 03028 default: 03029 rsbac_printk(KERN_WARNING "do_read_list(): wrong on-disk list version %u in file %s, expected %u - error!\n", 03030 list_version, 03031 name, RSBAC_LIST_DISK_VERSION); 03032 err = -RSBAC_EREADFAILED; 03033 goto end_read; 03034 } 03035 03036 /* get timestamp */ 03037 set_fs(KERNEL_DS); 03038 tmperr = file_p->f_op->read(file_p, 03039 (__u8 *) & timestamp, 03040 sizeof(timestamp), &file_p->f_pos); 03041 set_fs(oldfs); 03042 /* error? */ 03043 if (tmperr < sizeof(timestamp)) { 03044 rsbac_printk(KERN_WARNING "do_read_list(): timestamp read error from file %s!\n", 03045 name); 03046 err = -RSBAC_EREADFAILED; 03047 goto end_read; 03048 } 03049 03050 /* get list info */ 03051 set_fs(KERNEL_DS); 03052 tmperr = file_p->f_op->read(file_p, 03053 (__u8 *) list_info_p, 03054 sizeof(*list_info_p), &file_p->f_pos); 03055 set_fs(oldfs); 03056 /* error? */ 03057 if (tmperr < sizeof(*list_info_p)) { 03058 rsbac_printk(KERN_WARNING "do_read_list(): list info read error from file %s!\n", 03059 name); 03060 err = -RSBAC_EREADFAILED; 03061 goto end_read; 03062 } 03063 03064 /* list timed out? System time is measured in seconds. */ 03065 if (list_info_p->max_age 03066 && (timestamp + list_info_p->max_age) <= RSBAC_CURRENT_TIME) 03067 timeout = TRUE; 03068 03069 /* Valid key? */ 03070 if (list_info_p->key != list->info.key) { 03071 if (timeout) { 03072 rsbac_printk(KERN_WARNING "do_read_list(): accessing timed out list %s with wrong key, ignoring old contents!\n", 03073 name); 03074 goto end_read; 03075 } else { 03076 rsbac_printk(KERN_WARNING "do_read_list(): try to access list %s with wrong key!\n", 03077 name); 03078 err = -EPERM; 03079 goto end_read; 03080 } 03081 } 03082 03083 /* skip the rest, if ignore is requested */ 03084 if (list->flags & RSBAC_LIST_IGNORE_OLD) 03085 goto end_read; 03086 03087 switch (list_version) { 03088 case RSBAC_LIST_DISK_VERSION: 03089 set_fs(KERNEL_DS); 03090 tmperr = file_p->f_op->read(file_p, 03091 (char *) &lastchange, 03092 sizeof(lastchange), 03093 &file_p->f_pos); 03094 set_fs(oldfs); 03095 /* error? */ 03096 if (tmperr < sizeof(lastchange)) { 03097 rsbac_printk(KERN_WARNING "do_read_list(): lastchange read error from file %s!\n", 03098 name); 03099 err = -RSBAC_EREADFAILED; 03100 goto end_read; 03101 } 03102 break; 03103 case RSBAC_LIST_DISK_OLD_VERSION: 03104 break; 03105 default: 03106 break; 03107 } 03108 /* if wrong list version, try to get_conv */ 03109 if (list_info_p->version != list->info.version) { 03110 if (list->get_conv) 03111 conv = list->get_conv(list_info_p->version); 03112 if (!conv) { 03113 if (timeout) { 03114 rsbac_printk(KERN_WARNING "do_read_list(): accessing timed out list %s without conversion function, ignoring old contents!\n", 03115 name); 03116 goto end_read; 03117 } else { 03118 /* complain and set error, if ignore is not requested */ 03119 if (! 03120 (list-> 03121 flags & 03122 RSBAC_LIST_IGNORE_UNSUPP_VERSION)) { 03123 rsbac_printk(KERN_WARNING "do_read_list(): cannot convert list version %u of file %s to version %u!\n", 03124 list_info_p->version, 03125 name, 03126 list->info.version); 03127 err = -RSBAC_EINVALIDVERSION; 03128 } 03129 goto end_read; 03130 } 03131 } else { 03132 rsbac_printk(KERN_WARNING "do_read_list(): converting list version %u of file %s on device %02u:%02u to version %u!\n", 03133 list_info_p->version, 03134 name, 03135 RSBAC_MAJOR(list->device), 03136 RSBAC_MINOR(list->device), 03137 list->info.version); 03138 } 03139 } else { /* same version needs same sizes */ 03140 03141 if ((list_info_p->desc_size != list->info.desc_size) 03142 || (list_info_p->data_size != list->info.data_size) 03143 ) { 03144 if (timeout) { 03145 rsbac_printk(KERN_WARNING "do_read_list(): accessing timed out list %s with wrong desc or data size, ignoring old contents!\n", 03146 name); 03147 goto end_read; 03148 } else { 03149 rsbac_printk(KERN_WARNING "do_read_list(): desc or data size mismatch on list %s!\n", 03150 name); 03151 err = -RSBAC_EINVALIDLIST; 03152 goto end_read; 03153 } 03154 } 03155 } 03156 03157 /* get list count */ 03158 set_fs(KERNEL_DS); 03159 tmperr = file_p->f_op->read(file_p, 03160 (__u8 *) & list_count, 03161 sizeof(list_count), &file_p->f_pos); 03162 set_fs(oldfs); 03163 /* error? */ 03164 if (tmperr < sizeof(list_count)) { 03165 rsbac_printk(KERN_WARNING "do_read_list(): list count read error from file %s!\n", 03166 name); 03167 err = -RSBAC_EREADFAILED; 03168 goto end_read; 03169 } 03170 03171 /* alloc mem for old and converted item */ 03172 old_buf = 03173 rsbac_kmalloc(list_info_p->desc_size + list_info_p->data_size); 03174 if (!old_buf) { 03175 rsbac_printk(KERN_WARNING "do_read_list(): cannot allocate memory!\n"); 03176 err = -RSBAC_ENOMEM; 03177 goto end_read; 03178 } 03179 new_buf = 03180 rsbac_kmalloc(list->info.desc_size + list->info.data_size); 03181 if (!new_buf) { 03182 rsbac_printk(KERN_WARNING "do_read_list(): cannot allocate memory!\n"); 03183 rsbac_kfree(old_buf); 03184 err = -RSBAC_ENOMEM; 03185 goto end_read; 03186 } 03187 /* calculate data pointers */ 03188 if (list_info_p->data_size) 03189 old_data = old_buf + list_info_p->desc_size; 03190 else 03191 old_data = NULL; 03192 if (list->info.data_size) 03193 new_data = new_buf + list->info.desc_size; 03194 else 03195 new_data = NULL; 03196 03197 /* actual reading */ 03198 do { 03199 set_fs(KERNEL_DS); 03200 tmperr = file_p->f_op->read(file_p, 03201 (char *) &max_age, 03202 sizeof(max_age), 03203 &file_p->f_pos); 03204 set_fs(oldfs); 03205 if (conv) { 03206 set_fs(KERNEL_DS); 03207 tmperr = file_p->f_op->read(file_p, 03208 old_buf, 03209 list_info_p-> 03210 desc_size + 03211 list_info_p->data_size, 03212 &file_p->f_pos); 03213 set_fs(oldfs); 03214 if (tmperr > 0) { /* convert */ 03215 converr = conv(old_buf, old_data, 03216 new_buf, new_data); 03217 if (converr) 03218 tmperr = converr; 03219 } 03220 } else { 03221 set_fs(KERNEL_DS); 03222 tmperr = file_p->f_op->read(file_p, 03223 new_buf, 03224 list->info.desc_size + 03225 list->info.data_size, 03226 &file_p->f_pos); 03227 set_fs(oldfs); 03228 } 03229 /* if successful, add item */ 03230 if (tmperr > 0) { 03231 /* wait for write access to list */ 03232 rsbac_write_lock(&list->lock, &flags); 03233 add_item(list, max_age, new_buf, new_data); 03234 /* allow access */ 03235 rsbac_write_unlock(&list->lock, &flags); 03236 read_count++; 03237 /* 03238 rsbac_pr_debug(lists, "read item %i\n", user_aci.id); 03239 */ 03240 } 03241 } 03242 while (tmperr > 0); /* end of do */ 03243 03244 if (tmperr < 0) { 03245 rsbac_printk(KERN_WARNING "do_read_list(): read error from file %s!\n", 03246 name); 03247 err = -RSBAC_EREADFAILED; 03248 } 03249 rsbac_kfree(old_buf); 03250 rsbac_kfree(new_buf); 03251 03252 if (read_count != list_count) { 03253 rsbac_printk(KERN_WARNING "do_read_list(): read %lu, expected %u items from file %s!\n", 03254 read_count, list_count, name); 03255 err = -RSBAC_EREADFAILED; 03256 } 03257 03258 end_read: 03259 03260 rsbac_pr_debug(lists, "%lu entries read.\n", read_count); 03261 /* We do not need this file any more */ 03262 rsbac_read_close(file_p); 03263 rsbac_kfree(list_info_p); 03264 rsbac_kfree(file_p); 03265 return (err); 03266 }
static int do_read_lol_list | ( | struct rsbac_list_lol_reg_item_t * | list, | |
char * | name | |||
) | [static] |
Definition at line 3294 of file gen_lists.c.
References add_lol_item(), add_lol_subitem(), rsbac_list_lol_info_t::data_size, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::device, FALSE, rsbac_list_lol_reg_item_t::flags, rsbac_list_lol_reg_item_t::get_conv, rsbac_list_lol_reg_item_t::get_subconv, rsbac_list_lol_reg_item_t::info, rsbac_list_lol_info_t::key, rsbac_list_lol_reg_item_t::lock, NULL, RSBAC_EINVALIDLIST, RSBAC_EINVALIDVERSION, RSBAC_ENOMEM, RSBAC_EREADFAILED, rsbac_kfree(), rsbac_kmalloc(), RSBAC_LIST_DISK_OLD_VERSION, RSBAC_LIST_DISK_VERSION, RSBAC_LIST_IGNORE_OLD, RSBAC_LIST_IGNORE_UNSUPP_VERSION, rsbac_pr_debug, rsbac_printk(), rsbac_read_close(), rsbac_read_open(), rsbac_list_lol_info_t::subdata_size, rsbac_list_lol_info_t::subdesc_size, TRUE, and rsbac_list_lol_info_t::version.
Referenced by read_lol_list().
03295 { 03296 struct file *file_p; 03297 int err = 0; 03298 int tmperr; 03299 int converr; 03300 rsbac_version_t list_version; 03301 u_long read_count = 0; 03302 u_long flags; 03303 u_long sublen; 03304 u_long i; 03305 char *old_buf; 03306 char *new_buf; 03307 char *old_data; 03308 char *new_data; 03309 char *old_subbuf; 03310 char *new_subbuf; 03311 char *old_subdata; 03312 char *new_subdata; 03313 struct rsbac_list_lol_info_t *list_info_p; 03314 rsbac_list_count_t list_count; 03315 rsbac_time_t timestamp; 03316 struct rsbac_nanotime_t lastchange; 03317 rsbac_time_t max_age = 0; 03318 rsbac_list_conv_function_t *conv = NULL; 03319 rsbac_list_conv_function_t *subconv = NULL; 03320 rsbac_boolean_t timeout = FALSE; 03321 struct rsbac_list_lol_item_t *item_p; 03322 mm_segment_t oldfs; 03323 03324 list_info_p = rsbac_kmalloc(sizeof(*list_info_p)); 03325 if (!list_info_p) 03326 return -RSBAC_ENOMEM; 03327 file_p = rsbac_kmalloc(sizeof(*file_p)); 03328 if (!file_p) { 03329 rsbac_kfree(list_info_p); 03330 return -RSBAC_ENOMEM; 03331 } 03332 /* open file */ 03333 if ((err = rsbac_read_open(name, file_p, list->device))) { 03334 rsbac_kfree(list_info_p); 03335 rsbac_kfree(file_p); 03336 return (err); 03337 } 03338 03339 /* OK, now we can start reading */ 03340 /* There is a read function for this file, so check info and read as 03341 * many items as possible. A positive return value means a read success, 03342 * 0 end of file and a negative value an error. */ 03343 03344 /* Set current user space to kernel space, because read() writes */ 03345 /* to user space */ 03346 oldfs = get_fs(); 03347 set_fs(KERNEL_DS); 03348 03349 /* check gen-list on-disk version */ 03350 tmperr = file_p->f_op->read(file_p, 03351 (__u8 *) & list_version, 03352 sizeof(list_version), &file_p->f_pos); 03353 set_fs(oldfs); 03354 /* error? */ 03355 if (tmperr < sizeof(list_version)) { 03356 printk(KERN_WARNING 03357 "do_read_lol_list(): read error from file!\n"); 03358 err = -RSBAC_EREADFAILED; 03359 goto end_read; 03360 } 03361 /* if wrong list on-disk version, fail */ 03362 switch (list_version) { 03363 case RSBAC_LIST_DISK_VERSION: 03364 case RSBAC_LIST_DISK_OLD_VERSION: 03365 break; 03366 default: 03367 rsbac_printk(KERN_WARNING "do_read_lol_list(): wrong on-disk list version %u in file %s, expected %u - error!\n", 03368 list_version, 03369 name, RSBAC_LIST_DISK_VERSION); 03370 err = -RSBAC_EREADFAILED; 03371 goto end_read; 03372 } 03373 03374 /* get timestamp */ 03375 set_fs(KERNEL_DS); 03376 tmperr = file_p->f_op->read(file_p, 03377 (__u8 *) & timestamp, 03378 sizeof(timestamp), &file_p->f_pos); 03379 set_fs(oldfs); 03380 /* error? */ 03381 if (tmperr < sizeof(timestamp)) { 03382 rsbac_printk(KERN_WARNING "do_read_lol_list(): timestamp read error from file %s!\n", 03383 name); 03384 err = -RSBAC_EREADFAILED; 03385 goto end_read; 03386 } 03387 03388 /* get list info */ 03389 set_fs(KERNEL_DS); 03390 tmperr = file_p->f_op->read(file_p, 03391 (__u8 *) list_info_p, 03392 sizeof(*list_info_p), &file_p->f_pos); 03393 set_fs(oldfs); 03394 /* error? */ 03395 if (tmperr < sizeof(*list_info_p)) { 03396 rsbac_printk(KERN_WARNING "do_read_lol_list(): list info read error from file %s!\n", 03397 name); 03398 err = -RSBAC_EREADFAILED; 03399 goto end_read; 03400 } 03401 03402 /* list timed out? System time is measured in seconds. */ 03403 if (list_info_p->max_age 03404 && (timestamp + list_info_p->max_age) <= RSBAC_CURRENT_TIME) 03405 timeout = TRUE; 03406 03407 /* Valid key? */ 03408 if (list_info_p->key != list->info.key) { 03409 if (timeout) { 03410 rsbac_printk(KERN_WARNING "do_read_lol_list(): accessing timed out list %s with wrong key, ignoring old contents!\n", 03411 name); 03412 goto end_read; 03413 } else { 03414 rsbac_printk(KERN_WARNING "do_read_lol_list(): try to access list %s with wrong key!\n", 03415 name); 03416 err = -EPERM; 03417 goto end_read; 03418 } 03419 } 03420 03421 /* skip the rest, if ignore is requested */ 03422 if (list->flags & RSBAC_LIST_IGNORE_OLD) 03423 goto end_read; 03424 03425 switch (list_version) { 03426 case RSBAC_LIST_DISK_VERSION: 03427 set_fs(KERNEL_DS); 03428 tmperr = file_p->f_op->read(file_p, 03429 (char *) &lastchange, 03430 sizeof(lastchange), 03431 &file_p->f_pos); 03432 set_fs(oldfs); 03433 /* error? */ 03434 if (tmperr < sizeof(lastchange)) { 03435 rsbac_printk(KERN_WARNING "read_list(): lastchange read error from file %s!\n", 03436 name); 03437 err = -RSBAC_EREADFAILED; 03438 goto end_read; 03439 } 03440 break; 03441 case RSBAC_LIST_DISK_OLD_VERSION: 03442 break; 03443 default: 03444 break; 03445 } 03446 /* if wrong list version, try to get_conv */ 03447 if (list_info_p->version != list->info.version) { 03448 if (list->get_conv) 03449 conv = list->get_conv(list_info_p->version); 03450 if (list->get_subconv) 03451 subconv = list->get_subconv(list_info_p->version); 03452 if (!conv || !subconv) { 03453 if (timeout) { 03454 rsbac_printk(KERN_WARNING "do_read_lol_list(): accessing timed out list %s without both conversion functions, ignoring old contents!\n", 03455 name); 03456 goto end_read; 03457 } else { 03458 /* complain and set error, if ignore is not requested */ 03459 if (! 03460 (list-> 03461 flags & 03462 RSBAC_LIST_IGNORE_UNSUPP_VERSION)) { 03463 rsbac_printk(KERN_WARNING "do_read_lol_list(): cannot convert list version %u of file %s to version %u!\n", 03464 list_info_p->version, 03465 name, 03466 list->info.version); 03467 err = -RSBAC_EINVALIDVERSION; 03468 } 03469 goto end_read; 03470 } 03471 } else { 03472 rsbac_printk(KERN_WARNING "do_read_lol_list(): converting list version %u of file %s on device %02u:%02u to version %u!\n", 03473 list_info_p->version, 03474 name, 03475 RSBAC_MAJOR(list->device), 03476 RSBAC_MINOR(list->device), 03477 list->info.version); 03478 } 03479 } else { /* same version needs same sizes */ 03480 03481 if ((list_info_p->desc_size != list->info.desc_size) 03482 || (list_info_p->data_size != list->info.data_size) 03483 || (list_info_p->subdesc_size != 03484 list->info.subdesc_size) 03485 || (list_info_p->subdata_size != 03486 list->info.subdata_size) 03487 ) { 03488 if (timeout) { 03489 rsbac_printk(KERN_WARNING "do_read_lol_list(): accessing timed out list %s with wrong desc or data size(s), ignoring old contents!\n", 03490 name); 03491 goto end_read; 03492 } else { 03493 rsbac_printk(KERN_WARNING "do_read_lol_list(): desc or data size mismatch on list %s!\n", 03494 name); 03495 err = -RSBAC_EINVALIDLIST; 03496 goto end_read; 03497 } 03498 } 03499 } 03500 03501 /* get list count */ 03502 set_fs(KERNEL_DS); 03503 tmperr = file_p->f_op->read(file_p, 03504 (__u8 *) & list_count, 03505 sizeof(list_count), &file_p->f_pos); 03506 set_fs(oldfs); 03507 /* error? */ 03508 if (tmperr < sizeof(list_count)) { 03509 rsbac_printk(KERN_WARNING "do_read_lol_list(): list count read error from file %s!\n", 03510 name); 03511 err = -RSBAC_EREADFAILED; 03512 goto end_read; 03513 } 03514 03515 /* alloc mem for old and converted items */ 03516 old_buf = 03517 rsbac_kmalloc(list_info_p->desc_size + list_info_p->data_size); 03518 if (!old_buf) { 03519 rsbac_printk(KERN_WARNING "do_read_lol_list(): cannot allocate memory!\n"); 03520 err = -RSBAC_ENOMEM; 03521 goto end_read; 03522 } 03523 new_buf = 03524 rsbac_kmalloc(list->info.desc_size + list->info.data_size); 03525 if (!new_buf) { 03526 rsbac_printk(KERN_WARNING "do_read_lol_list(): cannot allocate memory!\n"); 03527 rsbac_kfree(old_buf); 03528 err = -RSBAC_ENOMEM; 03529 goto end_read; 03530 } 03531 old_subbuf = 03532 rsbac_kmalloc(list_info_p->subdesc_size + 03533 list_info_p->subdata_size); 03534 if (!old_subbuf) { 03535 rsbac_printk(KERN_WARNING "do_read_lol_list(): cannot allocate memory!\n"); 03536 rsbac_kfree(old_buf); 03537 rsbac_kfree(new_buf); 03538 err = -RSBAC_ENOMEM; 03539 goto end_read; 03540 } 03541 new_subbuf = 03542 rsbac_kmalloc(list->info.subdesc_size + 03543 list->info.subdata_size); 03544 if (!new_subbuf) { 03545 rsbac_printk(KERN_WARNING "do_read_lol_list(): cannot allocate memory!\n"); 03546 rsbac_kfree(old_buf); 03547 rsbac_kfree(new_buf); 03548 rsbac_kfree(old_subbuf); 03549 err = -RSBAC_ENOMEM; 03550 goto end_read; 03551 } 03552 /* calculate data pointers */ 03553 if (list_info_p->data_size) 03554 old_data = old_buf + list_info_p->desc_size; 03555 else 03556 old_data = NULL; 03557 if (list->info.data_size) 03558 new_data = new_buf + list->info.desc_size; 03559 else 03560 new_data = NULL; 03561 if (list_info_p->subdata_size) 03562 old_subdata = old_subbuf + list_info_p->subdesc_size; 03563 else 03564 old_subdata = NULL; 03565 if (list->info.subdata_size) 03566 new_subdata = new_subbuf + list->info.subdesc_size; 03567 else 03568 new_subdata = NULL; 03569 03570 /* actual reading */ 03571 do { 03572 set_fs(KERNEL_DS); 03573 tmperr = file_p->f_op->read(file_p, 03574 (char *) &max_age, 03575 sizeof(max_age), 03576 &file_p->f_pos); 03577 set_fs(oldfs); 03578 if (conv) { 03579 set_fs(KERNEL_DS); 03580 tmperr = file_p->f_op->read(file_p, 03581 old_buf, 03582 list_info_p-> 03583 desc_size + 03584 list_info_p->data_size, 03585 &file_p->f_pos); 03586 set_fs(oldfs); 03587 if (tmperr > 0) { /* convert */ 03588 converr = conv(old_buf, old_data, 03589 new_buf, new_data); 03590 if (converr) 03591 tmperr = converr; 03592 } 03593 } else { 03594 set_fs(KERNEL_DS); 03595 tmperr = file_p->f_op->read(file_p, 03596 new_buf, 03597 list->info.desc_size + 03598 list->info.data_size, 03599 &file_p->f_pos); 03600 set_fs(oldfs); 03601 } 03602 /* if successful, add item */ 03603 if (tmperr > 0) { 03604 /* wait for write access to list */ 03605 rsbac_write_lock(&list->lock, &flags); 03606 item_p = 03607 add_lol_item(list, max_age, new_buf, new_data); 03608 /* allow access */ 03609 rsbac_write_unlock(&list->lock, &flags); 03610 if (!item_p) { 03611 err = -RSBAC_ENOMEM; 03612 goto end_read_free; 03613 } 03614 read_count++; 03615 /* 03616 rsbac_pr_debug(lists, "read item %i\n", user_aci.id); 03617 */ 03618 set_fs(KERNEL_DS); 03619 tmperr = file_p->f_op->read(file_p, 03620 (__u8 *) & sublen, 03621 sizeof(sublen), 03622 &file_p->f_pos); 03623 set_fs(oldfs); 03624 /* if successful, read and add sublen subitems */ 03625 if (tmperr > 0) { 03626 for (i = 0; i < sublen; i++) { 03627 set_fs(KERNEL_DS); 03628 tmperr = file_p->f_op->read(file_p, 03629 (char 03630 *) 03631 &max_age, 03632 sizeof 03633 (max_age), 03634 &file_p-> 03635 f_pos); 03636 set_fs(oldfs); 03637 if (subconv) { 03638 set_fs(KERNEL_DS); 03639 tmperr = 03640 file_p->f_op-> 03641 read(file_p, 03642 old_subbuf, 03643 list_info_p-> 03644 subdesc_size + 03645 list_info_p-> 03646 subdata_size, 03647 &file_p->f_pos); 03648 set_fs(oldfs); 03649 if (tmperr > 0) { /* convert */ 03650 converr = 03651 subconv 03652 (old_subbuf, 03653 old_subdata, 03654 new_subbuf, 03655 new_subdata); 03656 if (converr) 03657 tmperr = 03658 converr; 03659 } 03660 } else { 03661 set_fs(KERNEL_DS); 03662 tmperr = 03663 file_p->f_op-> 03664 read(file_p, 03665 new_subbuf, 03666 list->info. 03667 subdesc_size + 03668 list->info. 03669 subdata_size, 03670 &file_p->f_pos); 03671 set_fs(oldfs); 03672 } 03673 if (tmperr > 0) { 03674 /* wait for write access to list */ 03675 rsbac_write_lock(&list-> 03676 lock, 03677 &flags); 03678 if (!add_lol_subitem 03679 (list, item_p, max_age, 03680 new_subbuf, 03681 new_subdata)) { 03682 rsbac_printk 03683 (KERN_WARNING 03684 "do_read_lol_list(): could not add subitem!\n"); 03685 i = sublen; 03686 tmperr = -1; 03687 } 03688 /* allow access */ 03689 rsbac_write_unlock(&list-> 03690 lock, 03691 &flags); 03692 } else { 03693 i = sublen; 03694 tmperr = -1; 03695 } 03696 } 03697 } 03698 } 03699 } 03700 while (tmperr > 0); /* end of do */ 03701 03702 if (tmperr < 0) { 03703 rsbac_printk(KERN_WARNING "do_read_lol_list(): read error from file %s!\n", 03704 name); 03705 err = -RSBAC_EREADFAILED; 03706 } 03707 03708 if (read_count != list_count) { 03709 rsbac_printk(KERN_WARNING "do_read_lol_list(): read %lu, expected %u items from file %s!\n", 03710 read_count, list_count, name); 03711 err = -RSBAC_EREADFAILED; 03712 } 03713 03714 end_read_free: 03715 rsbac_kfree(old_buf); 03716 rsbac_kfree(new_buf); 03717 rsbac_kfree(old_subbuf); 03718 rsbac_kfree(new_subbuf); 03719 03720 end_read: 03721 rsbac_pr_debug(lists, "%lu entries read.\n", read_count); 03722 /* We do not need this file any more */ 03723 rsbac_read_close(file_p); 03724 rsbac_kfree(list_info_p); 03725 rsbac_kfree(file_p); 03726 return err; 03727 } /* end of do_read_lol_list() */
static int do_rehash | ( | struct rsbac_list_reg_item_t * | list, | |
u_int | new_nr | |||
) | [static] |
Definition at line 10435 of file gen_lists.c.
References rsbac_list_reg_item_t::hashed, rsbac_list_reg_item_t::nr_hashes, RSBAC_EBUSY, RSBAC_ENOMEM, and rsbac_kmalloc().
Referenced by rsbac_list_auto_rehash().
10436 { 10437 struct rsbac_list_hashed_t * old_hashed; 10438 int i; 10439 struct rsbac_list_item_t *item_p; 10440 struct rsbac_list_item_t *next_item_p; 10441 u_int new_hash; 10442 u_int old_nr; 10443 10444 #ifdef CONFIG_RSBAC_LIST_TRANS 10445 for(i=0; i<list->nr_hashes; i++) 10446 if(list->hashed[i].ta_copied) 10447 return -RSBAC_EBUSY; 10448 #endif 10449 old_hashed = list->hashed; 10450 list->hashed = rsbac_kmalloc(new_nr*sizeof(struct rsbac_list_hashed_t)); 10451 if(!list->hashed) { 10452 list->hashed = old_hashed; 10453 return -RSBAC_ENOMEM; 10454 } 10455 memset(list->hashed, 0, new_nr*sizeof(struct rsbac_list_hashed_t)); 10456 old_nr = list->nr_hashes; 10457 list->nr_hashes = new_nr; 10458 for(i=0; i<old_nr; i++) { 10459 item_p = old_hashed[i].head; 10460 while(item_p) { 10461 next_item_p = item_p->next; 10462 new_hash = list->hash_function(&item_p[1], new_nr); 10463 if (!list->hashed[new_hash].head) { 10464 list->hashed[new_hash].head = item_p; 10465 list->hashed[new_hash].tail = item_p; 10466 list->hashed[new_hash].curr = item_p; 10467 list->hashed[new_hash].count = 1; 10468 item_p->prev = NULL; 10469 item_p->next = NULL; 10470 } else 10471 if (list->compare) 10472 insert_item_compare(list, &item_p[1], item_p); 10473 else 10474 insert_item_memcmp(list, &item_p[1], item_p); 10475 item_p = next_item_p; 10476 } 10477 } 10478 return 0; 10479 }
static void do_remove_item | ( | struct rsbac_list_reg_item_t * | list, | |
struct rsbac_list_item_t * | item_p, | |||
u_int | hash | |||
) | [inline, static] |
Definition at line 2406 of file gen_lists.c.
References rsbac_list_hashed_t::count, rsbac_list_hashed_t::curr, rsbac_list_reg_item_t::hashed, rsbac_list_hashed_t::head, rsbac_list_item_t::next, NULL, rsbac_list_item_t::prev, rsbac_kfree(), and rsbac_list_hashed_t::tail.
Referenced by remove_item(), rsbac_check_lists(), rsbac_list_check(), and rsbac_ta_list_add_ttl().
02409 { 02410 if (!list || !item_p) 02411 return; 02412 02413 if ((list->hashed[hash].head == item_p)) { /* item is head */ 02414 if ((list->hashed[hash].tail == item_p)) { /* item is head and tail = only item -> list will be empty */ 02415 list->hashed[hash].head = NULL; 02416 list->hashed[hash].tail = NULL; 02417 } else { /* item is head, but not tail -> next item becomes head */ 02418 item_p->next->prev = NULL; 02419 list->hashed[hash].head = item_p->next; 02420 }; 02421 } else { /* item is not head */ 02422 if ((list->hashed[hash].tail == item_p)) { /*item is not head, but tail -> previous item becomes tail */ 02423 item_p->prev->next = NULL; 02424 list->hashed[hash].tail = item_p->prev; 02425 } else { /* item is neither head nor tail -> item is cut out */ 02426 item_p->prev->next = item_p->next; 02427 item_p->next->prev = item_p->prev; 02428 } 02429 } 02430 /* curr is no longer valid -> reset */ 02431 list->hashed[hash].curr = NULL; 02432 /* adjust counter */ 02433 list->hashed[hash].count--; 02434 /* now we can remove the item from memory */ 02435 rsbac_kfree(item_p); 02436 } /* end of do_remove_item() */
static void do_remove_lol_item | ( | struct rsbac_list_lol_reg_item_t * | list, | |
struct rsbac_list_lol_item_t * | item_p, | |||
u_int | hash | |||
) | [static] |
Definition at line 2588 of file gen_lists.c.
References rsbac_list_lol_hashed_t::count, rsbac_list_lol_hashed_t::curr, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_item_t::head, rsbac_list_lol_hashed_t::head, rsbac_list_lol_reg_item_t::name, rsbac_list_item_t::next, rsbac_list_lol_item_t::next, NULL, rsbac_list_lol_item_t::prev, rsbac_kfree(), rsbac_printk(), and rsbac_list_lol_hashed_t::tail.
Referenced by remove_lol_item(), rsbac_list_lol_check(), rsbac_ta_list_lol_add_ttl(), rsbac_ta_list_lol_subremove(), and rsbac_ta_list_lol_subremove_count().
02591 { 02592 struct rsbac_list_item_t *subitem_p; 02593 struct rsbac_list_item_t *next_subitem_p; 02594 02595 if (!list || !item_p) 02596 return; 02597 02598 if ((list->hashed[hash].head == item_p)) { /* item is head */ 02599 if ((list->hashed[hash].tail == item_p)) { /* item is head and tail = only item -> list will be empty */ 02600 list->hashed[hash].head = NULL; 02601 list->hashed[hash].tail = NULL; 02602 } else { /* item is head, but not tail -> next item becomes head */ 02603 #ifdef CONFIG_RSBAC_DEBUG 02604 if (!item_p->next) { /* list corrupted! */ 02605 rsbac_printk(KERN_WARNING "do_remove_lol_item(): list %s corrupted: invalid next!\n", 02606 list->name); 02607 } else 02608 #endif 02609 { 02610 item_p->next->prev = NULL; 02611 list->hashed[hash].head = item_p->next; 02612 } 02613 } 02614 } else { /* item is not head */ 02615 if ((list->hashed[hash].tail == item_p)) { /*item is not head, but tail -> previous item becomes tail */ 02616 #ifdef CONFIG_RSBAC_DEBUG 02617 if (!item_p->prev) { /* list corrupted! */ 02618 rsbac_printk(KERN_WARNING "do_remove_lol_item(): list %s corrupted: invalid prev!\n", 02619 list->name); 02620 } else 02621 #endif 02622 { 02623 item_p->prev->next = NULL; 02624 list->hashed[hash].tail = item_p->prev; 02625 } 02626 } else { /* item is neither head nor tail -> item is cut out */ 02627 #ifdef CONFIG_RSBAC_DEBUG 02628 if (!item_p->prev) { /* list corrupted! */ 02629 rsbac_printk(KERN_WARNING "do_remove_lol_item(): list %s corrupted: invalid prev!\n", 02630 list->name); 02631 } else if (!item_p->next) { /* list corrupted! */ 02632 rsbac_printk(KERN_WARNING "do_remove_lol_item(): list %s corrupted: invalid next!\n", 02633 list->name); 02634 } else 02635 #endif 02636 { 02637 item_p->prev->next = item_p->next; 02638 item_p->next->prev = item_p->prev; 02639 } 02640 } 02641 } 02642 /* curr is no longer valid -> reset */ 02643 list->hashed[hash].curr = NULL; 02644 /* adjust counter */ 02645 list->hashed[hash].count--; 02646 /* first remove subitems */ 02647 subitem_p = item_p->head; 02648 while (subitem_p) { 02649 next_subitem_p = subitem_p->next; 02650 rsbac_kfree(subitem_p); 02651 subitem_p = next_subitem_p; 02652 } 02653 /* now we can remove the item from memory */ 02654 rsbac_kfree(item_p); 02655 }
static void do_remove_lol_subitem | ( | struct rsbac_list_lol_item_t * | sublist, | |
struct rsbac_list_item_t * | item_p | |||
) | [static] |
Definition at line 2541 of file gen_lists.c.
References rsbac_list_lol_item_t::count, rsbac_list_lol_item_t::curr, rsbac_list_lol_item_t::head, rsbac_list_item_t::next, NULL, rsbac_list_item_t::prev, rsbac_kfree(), and rsbac_list_lol_item_t::tail.
Referenced by remove_lol_subitem(), rsbac_list_lol_check(), rsbac_ta_list_lol_subadd_ttl(), and rsbac_ta_list_lol_subremove_count().
02543 { 02544 if (!sublist || !item_p) 02545 return; 02546 02547 if ((sublist->head == item_p)) { /* item is head */ 02548 if ((sublist->tail == item_p)) { /* item is head and tail = only item -> list will be empty */ 02549 sublist->head = NULL; 02550 sublist->tail = NULL; 02551 } else { /* item is head, but not tail -> next item becomes head */ 02552 item_p->next->prev = NULL; 02553 sublist->head = item_p->next; 02554 } 02555 } else { /* item is not head */ 02556 if ((sublist->tail == item_p)) { /*item is not head, but tail -> previous item becomes tail */ 02557 item_p->prev->next = NULL; 02558 sublist->tail = item_p->prev; 02559 } else { /* item is neither head nor tail -> item is cut out */ 02560 item_p->prev->next = item_p->next; 02561 item_p->next->prev = item_p->prev; 02562 } 02563 } 02564 /* curr is no longer valid -> reset */ 02565 sublist->curr = NULL; 02566 /* adjust counter */ 02567 sublist->count--; 02568 /* now we can remove the item from memory */ 02569 rsbac_kfree(item_p); 02570 }
static int fill_buffer | ( | struct rsbac_list_reg_item_t * | list, | |
struct rsbac_list_write_item_t ** | write_item_pp | |||
) | [static] |
Definition at line 3789 of file gen_lists.c.
References check_buffer(), rsbac_list_hashed_t::count, rsbac_list_buffer_t::data, rsbac_list_info_t::data_size, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::device, free_buffers(), rsbac_list_reg_item_t::hashed, rsbac_list_hashed_t::head, rsbac_list_reg_item_t::info, rsbac_list_reg_item_t::lastchange, rsbac_list_buffer_t::len, rsbac_list_reg_item_t::lock, rsbac_list_reg_item_t::name, rsbac_list_buffer_t::next, rsbac_list_reg_item_t::nr_hashes, NULL, RSBAC_ENOMEM, rsbac_kfree(), rsbac_kmalloc(), RSBAC_LIST_BUFFER_SIZE, RSBAC_LIST_DISK_VERSION, and RSBAC_LIST_MAX_FILENAME.
Referenced by rsbac_list_detach().
03791 { 03792 struct rsbac_list_write_item_t *write_item_p; 03793 struct rsbac_list_item_t *current_p; 03794 u_long flags; 03795 struct rsbac_list_buffer_t *buffer = NULL; 03796 rsbac_list_count_t allcount = 0; 03797 rsbac_version_t list_version = RSBAC_LIST_DISK_VERSION; 03798 rsbac_time_t timestamp = RSBAC_CURRENT_TIME; 03799 int i; 03800 03801 write_item_p = rsbac_kmalloc(sizeof(*write_item_p)); 03802 if (!write_item_p) { 03803 *write_item_pp = NULL; 03804 return (-RSBAC_ENOMEM); 03805 } 03806 03807 /* protect this list */ 03808 rsbac_read_lock(&list->lock, &flags); 03809 /* fill write_item */ 03810 write_item_p->prev = NULL; 03811 write_item_p->next = NULL; 03812 write_item_p->list = list; 03813 write_item_p->buffer = NULL; 03814 strncpy(write_item_p->name, list->name, RSBAC_LIST_MAX_FILENAME); 03815 write_item_p->name[RSBAC_LIST_MAX_FILENAME] = 0; 03816 write_item_p->device = list->device; 03817 03818 for (i=0; i<list->nr_hashes; i++) 03819 allcount += list->hashed[i].count; 03820 buffer = rsbac_kmalloc(RSBAC_LIST_BUFFER_SIZE); 03821 if (!buffer) { 03822 /* unprotect this list */ 03823 rsbac_read_unlock(&list->lock, &flags); 03824 rsbac_kfree(write_item_p); 03825 *write_item_pp = NULL; 03826 return (-RSBAC_ENOMEM); 03827 } 03828 write_item_p->buffer = buffer; 03829 buffer->len = 0; 03830 buffer->next = NULL; 03831 /* copy version */ 03832 memcpy(buffer->data, &list_version, sizeof(list_version)); 03833 buffer->len = sizeof(list_version); 03834 /* copy timestamp */ 03835 memcpy(buffer->data + buffer->len, 03836 ×tamp, sizeof(timestamp)); 03837 buffer->len += sizeof(timestamp); 03838 /* copy info */ 03839 memcpy(buffer->data + buffer->len, 03840 &list->info, sizeof(list->info)); 03841 buffer->len += sizeof(list->info); 03842 /* copy lastchange */ 03843 memcpy(buffer->data + buffer->len, 03844 &list->lastchange, sizeof(list->lastchange)); 03845 buffer->len += sizeof(list->lastchange); 03846 /* copy count */ 03847 memcpy(buffer->data + buffer->len, 03848 &allcount, sizeof(allcount)); 03849 buffer->len += sizeof(allcount); 03850 /* copy list */ 03851 for (i=0; i<list->nr_hashes; i++) { 03852 current_p = list->hashed[i].head; 03853 while (current_p) { 03854 if (check_buffer(&buffer, sizeof(current_p->max_age) + list->info.desc_size + list->info.data_size)) { 03855 /* unprotect this list */ 03856 rsbac_read_unlock(&list->lock, &flags); 03857 free_buffers(write_item_p->buffer); 03858 rsbac_kfree(write_item_p); 03859 *write_item_pp = NULL; 03860 return (-RSBAC_ENOMEM); 03861 } 03862 memcpy(buffer->data + buffer->len, 03863 ¤t_p->max_age, sizeof(current_p->max_age)); 03864 buffer->len += sizeof(current_p->max_age); 03865 memcpy(buffer->data + buffer->len, 03866 ((char *) current_p) + sizeof(*current_p), 03867 list->info.desc_size + list->info.data_size); 03868 buffer->len += list->info.desc_size + list->info.data_size; 03869 current_p = current_p->next; 03870 } 03871 } 03872 03873 *write_item_pp = write_item_p; 03874 03875 /* unprotect this list */ 03876 rsbac_read_unlock(&list->lock, &flags); 03877 03878 return 0; 03879 }
static int fill_lol_buffer | ( | struct rsbac_list_lol_reg_item_t * | list, | |
struct rsbac_list_lol_write_item_t ** | write_item_pp | |||
) | [static] |
Definition at line 4000 of file gen_lists.c.
References check_buffer(), rsbac_list_lol_hashed_t::count, rsbac_list_buffer_t::data, rsbac_list_lol_info_t::data_size, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::device, free_buffers(), rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_hashed_t::head, rsbac_list_lol_reg_item_t::info, rsbac_list_lol_reg_item_t::lastchange, rsbac_list_buffer_t::len, rsbac_list_lol_reg_item_t::lock, rsbac_list_item_t::max_age, rsbac_list_lol_reg_item_t::name, rsbac_list_buffer_t::next, rsbac_list_lol_reg_item_t::nr_hashes, NULL, RSBAC_ENOMEM, rsbac_kfree(), rsbac_kmalloc(), RSBAC_LIST_BUFFER_SIZE, RSBAC_LIST_DISK_VERSION, RSBAC_LIST_MAX_FILENAME, rsbac_pr_debug, rsbac_list_lol_info_t::subdata_size, and rsbac_list_lol_info_t::subdesc_size.
Referenced by rsbac_list_lol_detach().
04003 { 04004 struct rsbac_list_lol_write_item_t *write_item_p; 04005 struct rsbac_list_lol_item_t *current_p; 04006 struct rsbac_list_item_t *sub_p; 04007 u_long flags; 04008 struct rsbac_list_buffer_t *buffer = NULL; 04009 rsbac_list_count_t allcount = 0; 04010 rsbac_version_t list_version = RSBAC_LIST_DISK_VERSION; 04011 rsbac_time_t timestamp = RSBAC_CURRENT_TIME; 04012 int i; 04013 04014 write_item_p = rsbac_kmalloc(sizeof(*write_item_p)); 04015 if (!write_item_p) { 04016 *write_item_pp = NULL; 04017 return (-RSBAC_ENOMEM); 04018 } 04019 04020 rsbac_pr_debug(write, "Filling buffers for list of lists %s\n", 04021 list->name); 04022 rsbac_read_lock(&list->lock, &flags); 04023 04024 /* fill write_item */ 04025 write_item_p->prev = NULL; 04026 write_item_p->next = NULL; 04027 write_item_p->list = list; 04028 write_item_p->buffer = NULL; 04029 strncpy(write_item_p->name, list->name, RSBAC_LIST_MAX_FILENAME); 04030 write_item_p->name[RSBAC_LIST_MAX_FILENAME] = 0; 04031 write_item_p->device = list->device; 04032 04033 for (i=0; i<list->nr_hashes; i++) 04034 allcount += list->hashed[i].count; 04035 buffer = rsbac_kmalloc(RSBAC_LIST_BUFFER_SIZE); 04036 if (!buffer) { 04037 /* unprotect this list */ 04038 rsbac_read_unlock(&list->lock, &flags); 04039 rsbac_kfree(write_item_p); 04040 *write_item_pp = NULL; 04041 return (-RSBAC_ENOMEM); 04042 } 04043 write_item_p->buffer = buffer; 04044 buffer->len = 0; 04045 buffer->next = NULL; 04046 /* copy version */ 04047 memcpy(buffer->data, (char *) &list_version, sizeof(list_version)); 04048 buffer->len = sizeof(list_version); 04049 /* copy timestamp */ 04050 memcpy(buffer->data + buffer->len, 04051 (char *) ×tamp, sizeof(timestamp)); 04052 buffer->len += sizeof(timestamp); 04053 /* copy info */ 04054 memcpy(buffer->data + buffer->len, 04055 (char *) &list->info, sizeof(list->info)); 04056 buffer->len += sizeof(list->info); 04057 /* copy lastchange */ 04058 memcpy(buffer->data + buffer->len, 04059 (char *) &list->lastchange, sizeof(list->lastchange)); 04060 buffer->len += sizeof(list->lastchange); 04061 /* copy count */ 04062 memcpy(buffer->data + buffer->len, 04063 (char *) &allcount, sizeof(allcount)); 04064 buffer->len += sizeof(allcount); 04065 /* copy list */ 04066 for (i=0; i<list->nr_hashes; i++) { 04067 current_p = list->hashed[i].head; 04068 while (current_p) { 04069 if (check_buffer(&buffer, sizeof(current_p->max_age) 04070 + list->info.desc_size 04071 + list->info.data_size 04072 + sizeof(current_p->count))) { 04073 /* unprotect this list */ 04074 rsbac_read_unlock(&list->lock, &flags); 04075 free_buffers(write_item_p->buffer); 04076 rsbac_kfree(write_item_p); 04077 *write_item_pp = NULL; 04078 return (-RSBAC_ENOMEM); 04079 } 04080 memcpy(buffer->data + buffer->len, 04081 ¤t_p->max_age, sizeof(current_p->max_age)); 04082 buffer->len += sizeof(current_p->max_age); 04083 memcpy(buffer->data + buffer->len, 04084 ((char *) current_p) + sizeof(*current_p), 04085 list->info.desc_size + list->info.data_size); 04086 buffer->len += list->info.desc_size + list->info.data_size; 04087 memcpy(buffer->data + buffer->len, 04088 ¤t_p->count, sizeof(current_p->count)); 04089 buffer->len += sizeof(current_p->count); 04090 /* copy subitems */ 04091 sub_p = current_p->head; 04092 while (sub_p) { 04093 if (check_buffer(&buffer, sizeof(sub_p->max_age) 04094 + list->info.subdesc_size 04095 + list->info.subdata_size)) { 04096 /* unprotect this list */ 04097 rsbac_read_unlock(&list->lock, &flags); 04098 free_buffers(write_item_p->buffer); 04099 rsbac_kfree(write_item_p); 04100 *write_item_pp = NULL; 04101 return (-RSBAC_ENOMEM); 04102 } 04103 memcpy(buffer->data + buffer->len, 04104 &sub_p->max_age, sizeof(sub_p->max_age)); 04105 buffer->len += sizeof(sub_p->max_age); 04106 memcpy(buffer->data + buffer->len, 04107 ((char *) sub_p) + sizeof(*sub_p), 04108 list->info.subdesc_size + 04109 list->info.subdata_size); 04110 buffer->len += 04111 list->info.subdesc_size + 04112 list->info.subdata_size; 04113 sub_p = sub_p->next; 04114 } 04115 current_p = current_p->next; 04116 } 04117 } 04118 *write_item_pp = write_item_p; 04119 04120 /* unprotect this list */ 04121 rsbac_read_unlock(&list->lock, &flags); 04122 04123 return 0; 04124 }
void free_buffers | ( | struct rsbac_list_buffer_t * | buffer | ) |
Definition at line 3776 of file gen_lists.c.
References rsbac_list_buffer_t::len, rsbac_list_buffer_t::next, rsbac_kfree(), and rsbac_pr_debug.
Referenced by fill_buffer(), fill_lol_buffer(), rsbac_list_write_buffers(), and rsbac_list_write_lol_buffers().
03777 { 03778 struct rsbac_list_buffer_t * next; 03779 03780 while(buffer) { 03781 rsbac_pr_debug(write, "Freeing buffer of size %u\n", 03782 buffer->len); 03783 next = buffer->next; 03784 rsbac_kfree(buffer); 03785 buffer = next; 03786 } 03787 }
static struct rsbac_list_item_t* insert_item_compare | ( | struct rsbac_list_reg_item_t * | list, | |
void * | desc, | |||
struct rsbac_list_item_t * | new_item_p | |||
) | [inline, static] |
Definition at line 1110 of file gen_lists.c.
References rsbac_list_reg_item_t::compare, rsbac_list_hashed_t::count, rsbac_list_hashed_t::curr, rsbac_list_reg_item_t::hash_function, rsbac_list_reg_item_t::hashed, rsbac_list_hashed_t::head, rsbac_list_item_t::next, rsbac_list_reg_item_t::nr_hashes, NULL, rsbac_list_item_t::prev, and rsbac_list_hashed_t::tail.
Referenced by add_item().
01116 { 01117 struct rsbac_list_item_t *curr; 01118 u_int hash = 0; 01119 01120 if(list->hash_function) 01121 hash = list->hash_function(desc, list->nr_hashes); 01122 curr = list->hashed[hash].curr; 01123 if (!curr) 01124 curr = list->hashed[hash].head; 01125 if ((list->compare(desc, &curr[1]) > 0)) { 01126 curr = curr->next; 01127 while (curr && (list->compare(desc, &curr[1]) > 0) 01128 ) 01129 curr = curr->next; 01130 if (curr) { 01131 /* insert before curr */ 01132 new_item_p->prev = curr->prev; 01133 new_item_p->next = curr; 01134 curr->prev->next = new_item_p; 01135 curr->prev = new_item_p; 01136 } else { 01137 /* insert as last item */ 01138 new_item_p->prev = list->hashed[hash].tail; 01139 new_item_p->next = NULL; 01140 list->hashed[hash].tail->next = new_item_p; 01141 list->hashed[hash].tail = new_item_p; 01142 } 01143 } else { 01144 curr = curr->prev; 01145 while (curr && (list->compare(desc, &curr[1]) < 0) 01146 ) 01147 curr = curr->prev; 01148 if (curr) { 01149 /* insert after curr */ 01150 new_item_p->prev = curr; 01151 new_item_p->next = curr->next; 01152 curr->next->prev = new_item_p; 01153 curr->next = new_item_p; 01154 } else { 01155 /* insert as first item */ 01156 new_item_p->prev = NULL; 01157 new_item_p->next = list->hashed[hash].head; 01158 list->hashed[hash].head->prev = new_item_p; 01159 list->hashed[hash].head = new_item_p; 01160 } 01161 } 01162 list->hashed[hash].count++; 01163 list->hashed[hash].curr = new_item_p; 01164 return new_item_p; 01165 }
static struct rsbac_list_item_t* insert_item_memcmp | ( | struct rsbac_list_reg_item_t * | list, | |
void * | desc, | |||
struct rsbac_list_item_t * | new_item_p | |||
) | [inline, static] |
Definition at line 1167 of file gen_lists.c.
References rsbac_list_hashed_t::count, rsbac_list_hashed_t::curr, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::hash_function, rsbac_list_reg_item_t::hashed, rsbac_list_hashed_t::head, rsbac_list_reg_item_t::info, rsbac_list_item_t::next, rsbac_list_reg_item_t::nr_hashes, NULL, rsbac_list_item_t::prev, and rsbac_list_hashed_t::tail.
Referenced by add_item().
01173 { 01174 struct rsbac_list_item_t *curr; 01175 u_int hash = 0; 01176 01177 if(list->hash_function) 01178 hash = list->hash_function(desc, list->nr_hashes); 01179 curr = list->hashed[hash].curr; 01180 if (!curr) 01181 curr = list->hashed[hash].head; 01182 if (memcmp(desc, &curr[1], list->info.desc_size) > 0) { 01183 curr = curr->next; 01184 while (curr 01185 && (memcmp(desc, 01186 &curr[1], list->info.desc_size) > 0) 01187 ) 01188 curr = curr->next; 01189 if (curr) { 01190 /* insert before curr */ 01191 new_item_p->prev = curr->prev; 01192 new_item_p->next = curr; 01193 curr->prev->next = new_item_p; 01194 curr->prev = new_item_p; 01195 } else { 01196 /* insert as last item */ 01197 new_item_p->prev = list->hashed[hash].tail; 01198 new_item_p->next = NULL; 01199 list->hashed[hash].tail->next = new_item_p; 01200 list->hashed[hash].tail = new_item_p; 01201 } 01202 } else { 01203 curr = curr->prev; 01204 while (curr 01205 && (memcmp(desc, 01206 &curr[1], list->info.desc_size) < 0) 01207 ) 01208 curr = curr->prev; 01209 if (curr) { 01210 /* insert after curr */ 01211 new_item_p->prev = curr; 01212 new_item_p->next = curr->next; 01213 curr->next->prev = new_item_p; 01214 curr->next = new_item_p; 01215 } else { 01216 /* insert as first item */ 01217 new_item_p->prev = NULL; 01218 new_item_p->next = list->hashed[hash].head; 01219 list->hashed[hash].head->prev = new_item_p; 01220 list->hashed[hash].head = new_item_p; 01221 } 01222 } 01223 list->hashed[hash].count++; 01224 list->hashed[hash].curr = new_item_p; 01225 return new_item_p; 01226 }
static struct rsbac_list_lol_item_t* insert_lol_item_compare | ( | struct rsbac_list_lol_reg_item_t * | list, | |
void * | desc, | |||
struct rsbac_list_lol_item_t * | new_item_p | |||
) | [inline, static] |
Definition at line 1782 of file gen_lists.c.
References rsbac_list_lol_reg_item_t::compare, rsbac_list_lol_hashed_t::count, rsbac_list_lol_hashed_t::curr, rsbac_list_lol_item_t::curr, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_hashed_t::head, rsbac_list_lol_item_t::next, rsbac_list_item_t::next, rsbac_list_lol_reg_item_t::nr_hashes, NULL, rsbac_list_item_t::prev, rsbac_list_lol_item_t::prev, and rsbac_list_lol_hashed_t::tail.
Referenced by add_lol_item().
01789 { 01790 struct rsbac_list_lol_item_t *curr; 01791 u_int hash = 0; 01792 01793 if(list->hash_function) 01794 hash = list->hash_function(desc, list->nr_hashes); 01795 curr = list->hashed[hash].curr; 01796 if (!curr) 01797 curr = list->hashed[hash].head; 01798 if ((list->compare(desc, &curr[1]) > 0)) { 01799 curr = curr->next; 01800 while (curr && (list->compare(desc, &curr[1]) > 0) 01801 ) 01802 curr = curr->next; 01803 if (curr) { 01804 /* insert before curr */ 01805 new_item_p->prev = curr->prev; 01806 new_item_p->next = curr; 01807 curr->prev->next = new_item_p; 01808 curr->prev = new_item_p; 01809 } else { 01810 /* insert as last item */ 01811 new_item_p->prev = list->hashed[hash].tail; 01812 new_item_p->next = NULL; 01813 list->hashed[hash].tail->next = new_item_p; 01814 list->hashed[hash].tail = new_item_p; 01815 } 01816 } else { 01817 curr = curr->prev; 01818 while (curr && (list->compare(desc, &curr[1]) < 0) 01819 ) 01820 curr = curr->prev; 01821 if (curr) { 01822 /* insert after curr */ 01823 new_item_p->prev = curr; 01824 new_item_p->next = curr->next; 01825 curr->next->prev = new_item_p; 01826 curr->next = new_item_p; 01827 } else { 01828 /* insert as first item */ 01829 new_item_p->prev = NULL; 01830 new_item_p->next = list->hashed[hash].head; 01831 list->hashed[hash].head->prev = new_item_p; 01832 list->hashed[hash].head = new_item_p; 01833 } 01834 } 01835 list->hashed[hash].count++; 01836 list->hashed[hash].curr = new_item_p; 01837 return new_item_p; 01838 }
static struct rsbac_list_lol_item_t* insert_lol_item_memcmp | ( | struct rsbac_list_lol_reg_item_t * | list, | |
void * | desc, | |||
struct rsbac_list_lol_item_t * | new_item_p | |||
) | [inline, static] |
Definition at line 1840 of file gen_lists.c.
References rsbac_list_lol_hashed_t::count, rsbac_list_lol_hashed_t::curr, rsbac_list_lol_item_t::curr, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_hashed_t::head, rsbac_list_lol_reg_item_t::info, rsbac_list_lol_item_t::next, rsbac_list_item_t::next, rsbac_list_lol_reg_item_t::nr_hashes, NULL, rsbac_list_item_t::prev, rsbac_list_lol_item_t::prev, and rsbac_list_lol_hashed_t::tail.
Referenced by add_lol_item().
01847 { 01848 struct rsbac_list_lol_item_t *curr; 01849 u_int hash = 0; 01850 01851 if(list->hash_function) 01852 hash = list->hash_function(desc, list->nr_hashes); 01853 curr = list->hashed[hash].curr; 01854 if (!curr) 01855 curr = list->hashed[hash].head; 01856 if (memcmp(desc, &curr[1], list->info.desc_size) > 0) { 01857 curr = curr->next; 01858 while (curr 01859 && (memcmp(desc, 01860 &curr[1], list->info.desc_size) > 0) 01861 ) 01862 curr = curr->next; 01863 if (curr) { 01864 /* insert before curr */ 01865 new_item_p->prev = curr->prev; 01866 new_item_p->next = curr; 01867 curr->prev->next = new_item_p; 01868 curr->prev = new_item_p; 01869 } else { 01870 /* insert as last item */ 01871 new_item_p->prev = list->hashed[hash].tail; 01872 new_item_p->next = NULL; 01873 list->hashed[hash].tail->next = new_item_p; 01874 list->hashed[hash].tail = new_item_p; 01875 } 01876 } else { 01877 curr = curr->prev; 01878 while (curr 01879 && (memcmp(desc, 01880 &curr[1], list->info.desc_size) < 0) 01881 ) 01882 curr = curr->prev; 01883 if (curr) { 01884 /* insert after curr */ 01885 new_item_p->prev = curr; 01886 new_item_p->next = curr->next; 01887 curr->next->prev = new_item_p; 01888 curr->next = new_item_p; 01889 } else { 01890 /* insert as first item */ 01891 new_item_p->prev = NULL; 01892 new_item_p->next = list->hashed[hash].head; 01893 list->hashed[hash].head->prev = new_item_p; 01894 list->hashed[hash].head = new_item_p; 01895 } 01896 } 01897 list->hashed[hash].count++; 01898 list->hashed[hash].curr = new_item_p; 01899 return new_item_p; 01900 }
static struct rsbac_list_item_t* insert_lol_subitem_compare | ( | struct rsbac_list_lol_reg_item_t * | list, | |
struct rsbac_list_lol_item_t * | sublist, | |||
void * | subdesc, | |||
struct rsbac_list_item_t * | new_item_p | |||
) | [inline, static] |
Definition at line 1602 of file gen_lists.c.
References rsbac_list_lol_item_t::count, rsbac_list_lol_item_t::curr, rsbac_list_lol_item_t::head, rsbac_list_item_t::next, NULL, rsbac_list_item_t::prev, rsbac_list_lol_reg_item_t::subcompare, and rsbac_list_lol_item_t::tail.
Referenced by add_lol_subitem().
01612 { 01613 struct rsbac_list_item_t *curr; 01614 01615 curr = sublist->curr; 01616 if (!curr) 01617 curr = sublist->head; 01618 if ((list->subcompare(subdesc, &curr[1]) > 0)) { 01619 curr = curr->next; 01620 while (curr && (list->subcompare(subdesc, &curr[1]) > 0) 01621 ) 01622 curr = curr->next; 01623 if (curr) { 01624 /* insert before curr */ 01625 new_item_p->prev = curr->prev; 01626 new_item_p->next = curr; 01627 curr->prev->next = new_item_p; 01628 curr->prev = new_item_p; 01629 } else { 01630 /* insert as last item */ 01631 new_item_p->prev = sublist->tail; 01632 new_item_p->next = NULL; 01633 sublist->tail->next = new_item_p; 01634 sublist->tail = new_item_p; 01635 } 01636 } else { 01637 curr = curr->prev; 01638 while (curr && (list->subcompare(subdesc, &curr[1]) < 0) 01639 ) 01640 curr = curr->prev; 01641 if (curr) { 01642 /* insert after curr */ 01643 new_item_p->prev = curr; 01644 new_item_p->next = curr->next; 01645 curr->next->prev = new_item_p; 01646 curr->next = new_item_p; 01647 } else { 01648 /* insert as first item */ 01649 new_item_p->prev = NULL; 01650 new_item_p->next = sublist->head; 01651 sublist->head->prev = new_item_p; 01652 sublist->head = new_item_p; 01653 } 01654 } 01655 sublist->count++; 01656 sublist->curr = new_item_p; 01657 return new_item_p; 01658 }
static struct rsbac_list_item_t* insert_lol_subitem_memcmp | ( | struct rsbac_list_lol_reg_item_t * | list, | |
struct rsbac_list_lol_item_t * | sublist, | |||
void * | subdesc, | |||
struct rsbac_list_item_t * | new_item_p | |||
) | [inline, static] |
Definition at line 1660 of file gen_lists.c.
References rsbac_list_lol_item_t::count, rsbac_list_lol_item_t::curr, rsbac_list_lol_item_t::head, rsbac_list_lol_reg_item_t::info, rsbac_list_item_t::next, NULL, rsbac_list_item_t::prev, rsbac_list_lol_info_t::subdesc_size, and rsbac_list_lol_item_t::tail.
Referenced by add_lol_subitem().
01670 { 01671 struct rsbac_list_item_t *curr; 01672 01673 curr = sublist->curr; 01674 if (!curr) 01675 curr = sublist->head; 01676 if (memcmp(subdesc, &curr[1], list->info.subdesc_size) > 0) { 01677 curr = curr->next; 01678 while (curr 01679 && (memcmp(subdesc, 01680 &curr[1], list->info.subdesc_size) > 0) 01681 ) 01682 curr = curr->next; 01683 if (curr) { 01684 /* insert before curr */ 01685 new_item_p->prev = curr->prev; 01686 new_item_p->next = curr; 01687 curr->prev->next = new_item_p; 01688 curr->prev = new_item_p; 01689 } else { 01690 /* insert as last item */ 01691 new_item_p->prev = sublist->tail; 01692 new_item_p->next = NULL; 01693 sublist->tail->next = new_item_p; 01694 sublist->tail = new_item_p; 01695 } 01696 } else { 01697 curr = curr->prev; 01698 while (curr 01699 && (memcmp(subdesc, 01700 &curr[1], list->info.subdesc_size) < 0) 01701 ) 01702 curr = curr->prev; 01703 if (curr) { 01704 /* insert after curr */ 01705 new_item_p->prev = curr; 01706 new_item_p->next = curr->next; 01707 curr->next->prev = new_item_p; 01708 curr->next = new_item_p; 01709 } else { 01710 /* insert as first item */ 01711 new_item_p->prev = NULL; 01712 new_item_p->next = sublist->head; 01713 sublist->head->prev = new_item_p; 01714 sublist->head = new_item_p; 01715 } 01716 } 01717 sublist->count++; 01718 sublist->curr = new_item_p; 01719 return new_item_p; 01720 }
static struct rsbac_list_item_t* lookup_item | ( | struct rsbac_list_reg_item_t * | list, | |
void * | desc | |||
) | [static] |
Definition at line 156 of file gen_lists.c.
References rsbac_list_reg_item_t::compare, lookup_item_compare(), lookup_item_memcmp(), and NULL.
00158 { 00159 if (!list || !desc) 00160 return NULL; 00161 00162 if (list->compare) 00163 return lookup_item_compare(list, desc); 00164 else 00165 return lookup_item_memcmp(list, desc); 00166 }
static struct rsbac_list_item_t* lookup_item_compare | ( | struct rsbac_list_reg_item_t * | list, | |
void * | desc | |||
) | [inline, static] |
Definition at line 61 of file gen_lists.c.
References rsbac_list_reg_item_t::compare, rsbac_list_hashed_t::curr, rsbac_list_reg_item_t::hash_function, rsbac_list_reg_item_t::hashed, rsbac_list_hashed_t::head, rsbac_list_item_t::next, rsbac_list_reg_item_t::nr_hashes, NULL, and rsbac_list_item_t::prev.
Referenced by lookup_item().
00063 { 00064 struct rsbac_list_item_t *curr; 00065 u_int hash = 0; 00066 00067 if (!list || !desc || !list->compare) 00068 return NULL; 00069 00070 if(list->hash_function) 00071 hash = list->hash_function(desc, list->nr_hashes); 00072 curr = list->hashed[hash].curr; 00073 if (!curr) { 00074 curr = list->hashed[hash].head; 00075 if (!curr) 00076 return NULL; 00077 } 00078 /* if current item is not the right one, search... */ 00079 /* note: item desc is behind official struct */ 00080 if (list->compare(desc, &curr[1])) { 00081 if ((list->compare(desc, &curr[1]) > 0)) { 00082 curr = curr->next; 00083 while (curr && (list->compare(desc, &curr[1]) > 0) 00084 ) 00085 curr = curr->next; 00086 } else { 00087 curr = curr->prev; 00088 while (curr && (list->compare(desc, &curr[1]) < 0) 00089 ) 00090 curr = curr->prev; 00091 } 00092 if (curr) { 00093 /* keep for speedup */ 00094 list->hashed[hash].curr = curr; 00095 if (!list->compare(desc, &curr[1])) 00096 return curr; 00097 } 00098 /* NULL or not found */ 00099 return NULL; 00100 } 00101 /* it is the current item -> return it */ 00102 return curr; 00103 }
static struct rsbac_list_item_t* lookup_item_data | ( | struct rsbac_list_reg_item_t * | list, | |
void * | data, | |||
rsbac_list_data_compare_function_t | compare | |||
) | [static] |
Definition at line 348 of file gen_lists.c.
References lookup_item_data_compare(), lookup_item_data_memcmp(), and NULL.
Referenced by rsbac_ta_list_get_desc().
00353 { 00354 if (!list || !data) 00355 return NULL; 00356 00357 if (compare) 00358 return lookup_item_data_compare(list, data, compare); 00359 else 00360 return lookup_item_data_memcmp(list, data); 00361 }
static struct rsbac_list_item_t* lookup_item_data_compare | ( | struct rsbac_list_reg_item_t * | list, | |
void * | data, | |||
rsbac_list_data_compare_function_t | compare | |||
) | [inline, static] |
Definition at line 290 of file gen_lists.c.
References rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::hashed, rsbac_list_hashed_t::head, rsbac_list_reg_item_t::info, rsbac_list_item_t::max_age, rsbac_list_item_t::next, rsbac_list_reg_item_t::nr_hashes, and NULL.
Referenced by lookup_item_data().
00296 { 00297 struct rsbac_list_item_t *curr; 00298 int i; 00299 00300 if (!list || !data || !compare) 00301 return NULL; 00302 00303 for(i=0; i<list->nr_hashes; i++) { 00304 curr = list->hashed[i].head; 00305 00306 /* note: item desc is behind official struct */ 00307 while (curr 00308 && ((curr->max_age && (curr->max_age <= RSBAC_CURRENT_TIME)) 00309 || compare((char *) curr + sizeof(*curr) + 00310 list->info.desc_size, data) 00311 ) 00312 ) 00313 curr = curr->next; 00314 if(curr) 00315 return curr; 00316 } 00317 return NULL; 00318 }
static struct rsbac_list_item_t* lookup_item_data_memcmp | ( | struct rsbac_list_reg_item_t * | list, | |
void * | data | |||
) | [inline, static] |
Definition at line 320 of file gen_lists.c.
References rsbac_list_info_t::data_size, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::hashed, rsbac_list_hashed_t::head, rsbac_list_reg_item_t::info, rsbac_list_item_t::max_age, rsbac_list_item_t::next, rsbac_list_reg_item_t::nr_hashes, and NULL.
Referenced by lookup_item_data().
00323 { 00324 struct rsbac_list_item_t *curr; 00325 int i; 00326 00327 if (!list || !data) 00328 return NULL; 00329 00330 for(i=0; i<list->nr_hashes; i++) { 00331 curr = list->hashed[i].head; 00332 00333 /* note: item desc is behind official struct */ 00334 while (curr 00335 && ((curr->max_age && (curr->max_age <= RSBAC_CURRENT_TIME)) 00336 || memcmp(data, 00337 &curr[1] + list->info.desc_size, 00338 list->info.data_size) 00339 ) 00340 ) 00341 curr = curr->next; 00342 if(curr) 00343 return curr; 00344 } 00345 return NULL; 00346 }
static struct rsbac_list_item_t* lookup_item_memcmp | ( | struct rsbac_list_reg_item_t * | list, | |
void * | desc | |||
) | [inline, static] |
Definition at line 105 of file gen_lists.c.
References rsbac_list_hashed_t::curr, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::hash_function, rsbac_list_reg_item_t::hashed, rsbac_list_hashed_t::head, rsbac_list_reg_item_t::info, rsbac_list_item_t::next, rsbac_list_reg_item_t::nr_hashes, NULL, and rsbac_list_item_t::prev.
Referenced by lookup_item().
00108 { 00109 struct rsbac_list_item_t *curr; 00110 u_int hash = 0; 00111 00112 if (!list || !desc) 00113 return NULL; 00114 00115 if(list->hash_function) 00116 hash = list->hash_function(desc, list->nr_hashes); 00117 curr = list->hashed[hash].curr; 00118 if (!curr) { 00119 curr = list->hashed[hash].head; 00120 if (!curr) 00121 return NULL; 00122 } 00123 /* if current item is not the right one, search... */ 00124 /* note: item desc is behind official struct */ 00125 if (memcmp(desc, &curr[1], list->info.desc_size)) { 00126 if (memcmp(desc, &curr[1], list->info.desc_size) > 0) { 00127 curr = curr->next; 00128 while (curr 00129 && (memcmp(desc, 00130 &curr[1], 00131 list->info.desc_size) > 0) 00132 ) 00133 curr = curr->next; 00134 } else { 00135 curr = curr->prev; 00136 while (curr 00137 && (memcmp(desc, 00138 &curr[1], 00139 list->info.desc_size) < 0) 00140 ) 00141 curr = curr->prev; 00142 } 00143 if (curr) { 00144 /* keep for speedup */ 00145 list->hashed[hash].curr = curr; 00146 if (!memcmp(desc, &curr[1], list->info.desc_size)) 00147 return curr; 00148 } 00149 /* not found */ 00150 return NULL; 00151 } 00152 /* it is the current item -> return it */ 00153 return curr; 00154 }
static struct rsbac_list_lol_item_t* lookup_lol_item | ( | struct rsbac_list_lol_reg_item_t * | list, | |
void * | desc | |||
) | [static] |
Definition at line 693 of file gen_lists.c.
References rsbac_list_lol_reg_item_t::compare, lookup_lol_item_compare(), lookup_lol_item_memcmp(), and NULL.
Referenced by remove_lol_item(), rsbac_ta_list_lol_add_ttl(), rsbac_ta_list_lol_exist(), rsbac_ta_list_lol_get_all_subdata(), rsbac_ta_list_lol_get_all_subdesc_ttl(), rsbac_ta_list_lol_get_all_subitems_ttl(), rsbac_ta_list_lol_get_data_ttl(), rsbac_ta_list_lol_get_max_subdesc(), rsbac_ta_list_lol_get_next_desc(), rsbac_ta_list_lol_get_subdata_ttl(), rsbac_ta_list_lol_remove(), rsbac_ta_list_lol_subadd_ttl(), rsbac_ta_list_lol_subcount(), rsbac_ta_list_lol_subexist(), rsbac_ta_list_lol_subexist_compare(), rsbac_ta_list_lol_subremove(), rsbac_ta_list_lol_subremove_all(), and rsbac_ta_list_lol_subremove_count().
00696 { 00697 if (!list || !desc) 00698 return NULL; 00699 00700 if (list->compare) 00701 return lookup_lol_item_compare(list, desc); 00702 else 00703 return lookup_lol_item_memcmp(list, desc); 00704 }
static struct rsbac_list_lol_item_t* lookup_lol_item_compare | ( | struct rsbac_list_lol_reg_item_t * | list, | |
void * | desc | |||
) | [inline, static] |
Definition at line 595 of file gen_lists.c.
References rsbac_list_lol_reg_item_t::compare, rsbac_list_lol_hashed_t::curr, rsbac_list_lol_item_t::curr, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_hashed_t::head, rsbac_list_item_t::next, rsbac_list_lol_reg_item_t::nr_hashes, NULL, and rsbac_list_item_t::prev.
Referenced by lookup_lol_item().
00599 { 00600 struct rsbac_list_lol_item_t *curr; 00601 u_int hash = 0; 00602 00603 if (!list || !desc || !list->compare) 00604 return NULL; 00605 00606 if(list->hash_function) 00607 hash = list->hash_function(desc, list->nr_hashes); 00608 curr = list->hashed[hash].curr; 00609 if (!curr) { 00610 curr = list->hashed[hash].head; 00611 if (!curr) 00612 return NULL; 00613 } 00614 /* if current item is not the right one, search... */ 00615 /* note: item desc is behind official struct */ 00616 if (list->compare(desc, &curr[1])) { 00617 if ((list->compare(desc, &curr[1]) > 0)) { 00618 curr = curr->next; 00619 while (curr && (list->compare(desc, &curr[1]) > 0) 00620 ) 00621 curr = curr->next; 00622 } else { 00623 curr = curr->prev; 00624 while (curr && (list->compare(desc, &curr[1]) < 0) 00625 ) 00626 curr = curr->prev; 00627 } 00628 if (curr) { 00629 /* keep for speedup */ 00630 list->hashed[hash].curr = curr; 00631 if (!list->compare(desc, &curr[1])) 00632 return curr; 00633 } 00634 /* not found */ 00635 return NULL; 00636 } 00637 /* it is the current item -> return it */ 00638 return curr; 00639 }
static struct rsbac_list_lol_item_t* lookup_lol_item_data | ( | struct rsbac_list_lol_reg_item_t * | list, | |
void * | data, | |||
rsbac_list_data_compare_function_t | compare | |||
) | [static] |
Definition at line 884 of file gen_lists.c.
References lookup_lol_item_data_compare(), lookup_lol_item_data_memcmp(), and NULL.
Referenced by rsbac_ta_list_lol_get_desc().
00890 { 00891 if (!list || !data) 00892 return NULL; 00893 00894 if (compare) 00895 return lookup_lol_item_data_compare(list, data, compare); 00896 else 00897 return lookup_lol_item_data_memcmp(list, data); 00898 }
static struct rsbac_list_lol_item_t* lookup_lol_item_data_compare | ( | struct rsbac_list_lol_reg_item_t * | list, | |
void * | data, | |||
rsbac_list_data_compare_function_t | compare | |||
) | [inline, static] |
Definition at line 828 of file gen_lists.c.
References rsbac_list_lol_item_t::curr, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_hashed_t::head, rsbac_list_lol_reg_item_t::info, rsbac_list_item_t::max_age, rsbac_list_lol_item_t::next, rsbac_list_lol_reg_item_t::nr_hashes, and NULL.
Referenced by lookup_lol_item_data().
00832 { 00833 struct rsbac_list_lol_item_t *curr; 00834 int i; 00835 00836 if (!list || !data || !compare) 00837 return NULL; 00838 00839 for(i=0; i<list->nr_hashes; i++) { 00840 curr = list->hashed[i].head; 00841 00842 /* note: item desc is behind official struct */ 00843 while (curr 00844 && ((curr->max_age && (curr->max_age <= RSBAC_CURRENT_TIME)) 00845 || compare((char *) curr + sizeof(*curr) + 00846 list->info.desc_size, data) 00847 ) 00848 ) 00849 curr = curr->next; 00850 if(curr) 00851 return curr; 00852 } 00853 return NULL; 00854 }
static struct rsbac_list_lol_item_t* lookup_lol_item_data_memcmp | ( | struct rsbac_list_lol_reg_item_t * | list, | |
void * | data | |||
) | [inline, static] |
Definition at line 856 of file gen_lists.c.
References rsbac_list_lol_item_t::curr, rsbac_list_lol_info_t::data_size, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_hashed_t::head, rsbac_list_lol_reg_item_t::info, rsbac_list_item_t::max_age, rsbac_list_item_t::next, rsbac_list_lol_reg_item_t::nr_hashes, and NULL.
Referenced by lookup_lol_item_data().
00859 { 00860 struct rsbac_list_lol_item_t *curr; 00861 int i; 00862 00863 if (!list || !data) 00864 return NULL; 00865 00866 for(i=0; i<list->nr_hashes; i++) { 00867 curr = list->hashed[i].head; 00868 00869 /* note: item desc is behind official struct */ 00870 while (curr 00871 && ((curr->max_age && (curr->max_age <= RSBAC_CURRENT_TIME)) 00872 || memcmp(data, 00873 &curr[1] + list->info.desc_size, 00874 list->info.data_size) 00875 ) 00876 ) 00877 curr = curr->next; 00878 if(curr) 00879 return curr; 00880 } 00881 return NULL; 00882 }
static struct rsbac_list_lol_item_t* lookup_lol_item_memcmp | ( | struct rsbac_list_lol_reg_item_t * | list, | |
void * | desc | |||
) | [inline, static] |
Definition at line 641 of file gen_lists.c.
References rsbac_list_lol_hashed_t::curr, rsbac_list_lol_item_t::curr, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_hashed_t::head, rsbac_list_lol_reg_item_t::info, rsbac_list_item_t::next, rsbac_list_lol_reg_item_t::nr_hashes, NULL, and rsbac_list_item_t::prev.
Referenced by lookup_lol_item().
00645 { 00646 struct rsbac_list_lol_item_t *curr; 00647 u_int hash = 0; 00648 00649 if (!list || !desc) 00650 return NULL; 00651 00652 if(list->hash_function) 00653 hash = list->hash_function(desc, list->nr_hashes); 00654 curr = list->hashed[hash].curr; 00655 if (!curr) { 00656 curr = list->hashed[hash].head; 00657 if (!curr) 00658 return NULL; 00659 } 00660 /* if current item is not the right one, search... */ 00661 /* note: item desc is behind official struct */ 00662 if (memcmp(desc, &curr[1], list->info.desc_size)) { 00663 if (memcmp(desc, &curr[1], list->info.desc_size) > 0) { 00664 curr = curr->next; 00665 while (curr 00666 && (memcmp(desc, 00667 &curr[1], 00668 list->info.desc_size) > 0) 00669 ) 00670 curr = curr->next; 00671 } else { 00672 curr = curr->prev; 00673 while (curr 00674 && (memcmp(desc, 00675 &curr[1], 00676 list->info.desc_size) < 0) 00677 ) 00678 curr = curr->prev; 00679 } 00680 if (curr) { 00681 /* keep for speedup */ 00682 list->hashed[hash].curr = curr; 00683 if (!memcmp(desc, &curr[1], list->info.desc_size)) 00684 return curr; 00685 } 00686 /* not found */ 00687 return NULL; 00688 } 00689 /* it is the current item -> return it */ 00690 return curr; 00691 }
static struct rsbac_list_lol_reg_item_t* lookup_lol_reg | ( | struct rsbac_list_lol_reg_item_t * | handle | ) | [static] |
Definition at line 1048 of file gen_lists.c.
References rsbac_list_lol_reg_head_t::curr, handle, rsbac_list_lol_reg_head_t::head, lol_reg_head, rsbac_list_lol_reg_item_t::next, NULL, and rsbac_pr_debug.
Referenced by remove_lol_reg(), rsbac_list_lol_destroy(), rsbac_list_lol_detach(), rsbac_list_lol_max_items(), and rsbac_list_lol_no_write().
01051 { 01052 struct rsbac_list_lol_reg_item_t *curr = lol_reg_head.curr; 01053 01054 if (!handle) 01055 return NULL; 01056 /* if there is no current item or it is not the right one, search... */ 01057 if (curr != handle) { 01058 curr = lol_reg_head.head; 01059 while (curr && curr != handle) 01060 curr = curr->next; 01061 if (curr) 01062 lol_reg_head.curr = curr; 01063 else 01064 rsbac_pr_debug(lists, "Lookup of unknown list handle %p\n", 01065 handle); 01066 } 01067 /* it is the current item -> return it */ 01068 return curr; 01069 }
static struct rsbac_list_lol_reg_item_t* lookup_lol_reg_name | ( | char * | name, | |
kdev_t | device | |||
) | [static] |
Definition at line 1071 of file gen_lists.c.
References rsbac_list_lol_reg_head_t::curr, rsbac_list_lol_reg_item_t::device, rsbac_list_lol_reg_head_t::head, lol_reg_head, rsbac_list_lol_reg_item_t::name, rsbac_list_lol_reg_item_t::next, NULL, RSBAC_LIST_MAX_FILENAME, and rsbac_pr_debug.
Referenced by rsbac_list_lol_register_hashed(), and rsbac_list_register_hashed().
01073 { 01074 struct rsbac_list_lol_reg_item_t *curr = lol_reg_head.curr; 01075 01076 if (!name) 01077 return NULL; 01078 /* if there is no current item or it is not the right one, search... */ 01079 if (!curr || (strncmp(curr->name, name, RSBAC_LIST_MAX_FILENAME) 01080 || (RSBAC_MAJOR(curr->device) != RSBAC_MAJOR(device)) 01081 || (RSBAC_MINOR(curr->device) != RSBAC_MINOR(device)) 01082 ) 01083 ) { 01084 curr = lol_reg_head.head; 01085 while (curr 01086 && 01087 (strncmp(curr->name, name, RSBAC_LIST_MAX_FILENAME) 01088 || (RSBAC_MAJOR(curr->device) != 01089 RSBAC_MAJOR(device)) 01090 || (RSBAC_MINOR(curr->device) != 01091 RSBAC_MINOR(device)) 01092 ) 01093 ) 01094 curr = curr->next; 01095 if (curr) 01096 lol_reg_head.curr = curr; 01097 else 01098 rsbac_pr_debug(lists, "Lookup of unknown list name %s " 01099 "on device %02u:%02u\n", name, 01100 RSBAC_MAJOR(device), 01101 RSBAC_MINOR(device)); 01102 } 01103 /* it is the current item -> return it */ 01104 return curr; 01105 }
static struct rsbac_list_item_t* lookup_lol_subitem | ( | struct rsbac_list_lol_reg_item_t * | list, | |
struct rsbac_list_lol_item_t * | sublist, | |||
void * | subdesc | |||
) | [static] |
Definition at line 549 of file gen_lists.c.
References lookup_lol_subitem_compare(), lookup_lol_subitem_memcmp(), NULL, and rsbac_list_lol_reg_item_t::subcompare.
Referenced by remove_lol_subitem(), rsbac_ta_list_lol_get_subdata_ttl(), rsbac_ta_list_lol_subadd_ttl(), rsbac_ta_list_lol_subexist(), and rsbac_ta_list_lol_subremove().
00556 { 00557 if (!list || !sublist || !subdesc) 00558 return NULL; 00559 00560 if (list->subcompare) 00561 return lookup_lol_subitem_compare(list, sublist, subdesc, 00562 list->subcompare); 00563 else 00564 return lookup_lol_subitem_memcmp(list, sublist, subdesc); 00565 }
static struct rsbac_list_item_t* lookup_lol_subitem_compare | ( | struct rsbac_list_lol_reg_item_t * | list, | |
struct rsbac_list_lol_item_t * | sublist, | |||
void * | subdesc, | |||
rsbac_list_compare_function_t | compare | |||
) | [inline, static] |
Definition at line 448 of file gen_lists.c.
References compare(), rsbac_list_lol_item_t::curr, rsbac_list_lol_item_t::head, and NULL.
Referenced by lookup_lol_subitem().
00457 { 00458 struct rsbac_list_item_t *curr; 00459 00460 if (!list || !sublist || !subdesc || !compare) 00461 return NULL; 00462 00463 curr = sublist->curr; 00464 if (!curr) { 00465 curr = sublist->head; 00466 if (!curr) 00467 return NULL; 00468 } 00469 /* if current item is not the right one, search... */ 00470 /* note: item desc is behind official struct */ 00471 if (compare(&curr[1], subdesc)) { 00472 if ((compare(&curr[1], subdesc) < 0)) { 00473 curr = curr->next; 00474 while (curr && (compare(&curr[1], subdesc) < 0) 00475 ) 00476 curr = curr->next; 00477 } else { 00478 curr = curr->prev; 00479 while (curr && (compare(&curr[1], subdesc) > 0) 00480 ) 00481 curr = curr->prev; 00482 } 00483 if (curr) { 00484 /* keep for speedup */ 00485 sublist->curr = curr; 00486 if (!compare(&curr[1], subdesc)) 00487 return curr; 00488 } 00489 /* not found */ 00490 return NULL; 00491 } 00492 /* it is the current item -> return it */ 00493 return curr; 00494 }
static struct rsbac_list_item_t* lookup_lol_subitem_memcmp | ( | struct rsbac_list_lol_reg_item_t * | list, | |
struct rsbac_list_lol_item_t * | sublist, | |||
void * | subdesc | |||
) | [inline, static] |
Definition at line 496 of file gen_lists.c.
References rsbac_list_lol_item_t::curr, rsbac_list_lol_item_t::head, rsbac_list_lol_reg_item_t::info, rsbac_list_item_t::next, NULL, rsbac_list_item_t::prev, and rsbac_list_lol_info_t::subdesc_size.
Referenced by lookup_lol_subitem().
00503 { 00504 struct rsbac_list_item_t *curr; 00505 00506 if (!list || !sublist || !subdesc) 00507 return NULL; 00508 00509 curr = sublist->curr; 00510 if (!curr) { 00511 curr = sublist->head; 00512 if (!curr) 00513 return NULL; 00514 } 00515 /* if current item is not the right one, search... */ 00516 /* note: item desc is behind official struct */ 00517 if (memcmp(subdesc, &curr[1], list->info.subdesc_size)) { 00518 if (memcmp(subdesc, &curr[1], list->info.subdesc_size) > 0) { 00519 curr = curr->next; 00520 while (curr 00521 && (memcmp(subdesc, 00522 &curr[1], 00523 list->info.subdesc_size) > 0) 00524 ) 00525 curr = curr->next; 00526 } else { 00527 curr = curr->prev; 00528 while (curr 00529 && (memcmp(subdesc, 00530 &curr[1], 00531 list->info.subdesc_size) < 0) 00532 ) 00533 curr = curr->prev; 00534 } 00535 if (curr) { 00536 /* keep for speedup */ 00537 sublist->curr = curr; 00538 if (!memcmp(subdesc, 00539 &curr[1], list->info.subdesc_size)) 00540 return curr; 00541 } 00542 /* not found */ 00543 return NULL; 00544 } 00545 /* it is the current item -> return it */ 00546 return curr; 00547 }
static struct rsbac_list_item_t* lookup_lol_subitem_user_compare | ( | struct rsbac_list_lol_reg_item_t * | list, | |
struct rsbac_list_lol_item_t * | sublist, | |||
void * | subdesc, | |||
rsbac_list_compare_function_t | compare | |||
) | [inline, static] |
Definition at line 567 of file gen_lists.c.
References compare(), rsbac_list_lol_item_t::head, rsbac_list_item_t::next, and NULL.
Referenced by rsbac_ta_list_lol_subexist_compare().
00577 { 00578 struct rsbac_list_item_t *curr; 00579 00580 if (!list || !sublist || !subdesc || !compare) 00581 return NULL; 00582 00583 curr = sublist->head; 00584 /* note: item desc is behind official struct */ 00585 while (curr) { 00586 if (!compare(&curr[1], subdesc)) 00587 return curr; 00588 curr = curr->next; 00589 } 00590 return curr; 00591 }
static struct rsbac_list_reg_item_t* lookup_reg | ( | struct rsbac_list_reg_item_t * | handle | ) | [static] |
Definition at line 986 of file gen_lists.c.
References rsbac_list_reg_head_t::curr, handle, rsbac_list_reg_head_t::head, rsbac_list_reg_item_t::next, NULL, reg_head, and rsbac_pr_debug.
Referenced by remove_reg(), rsbac_list_destroy(), rsbac_list_detach(), rsbac_list_max_items(), and rsbac_list_no_write().
00989 { 00990 struct rsbac_list_reg_item_t *curr = reg_head.curr; 00991 00992 if (!handle) 00993 return NULL; 00994 /* if there is no current item or it is not the right one, search... */ 00995 if (curr != handle) { 00996 curr = reg_head.head; 00997 while (curr && curr != handle) 00998 curr = curr->next; 00999 if (curr) 01000 reg_head.curr = curr; 01001 else 01002 rsbac_pr_debug(lists, 01003 "Lookup of unknown list handle %p\n", 01004 handle); 01005 } 01006 /* it is the current item -> return it */ 01007 return curr; 01008 }
static struct rsbac_list_reg_item_t* lookup_reg_name | ( | char * | name, | |
kdev_t | device | |||
) | [static] |
Definition at line 1010 of file gen_lists.c.
References rsbac_list_reg_head_t::curr, rsbac_list_reg_item_t::device, rsbac_list_reg_head_t::head, rsbac_list_reg_item_t::name, rsbac_list_reg_item_t::next, NULL, reg_head, RSBAC_LIST_MAX_FILENAME, and rsbac_pr_debug.
Referenced by rsbac_list_lol_register_hashed(), and rsbac_list_register_hashed().
01012 { 01013 struct rsbac_list_reg_item_t *curr = reg_head.curr; 01014 01015 if (!name) 01016 return NULL; 01017 /* if there is no current item or it is not the right one, search... */ 01018 if (!curr || (strncmp(curr->name, name, RSBAC_LIST_MAX_FILENAME) 01019 || (RSBAC_MAJOR(curr->device) != RSBAC_MAJOR(device)) 01020 || (RSBAC_MINOR(curr->device) != RSBAC_MINOR(device)) 01021 ) 01022 ) { 01023 curr = reg_head.head; 01024 while (curr 01025 && 01026 (strncmp(curr->name, name, RSBAC_LIST_MAX_FILENAME) 01027 || (RSBAC_MAJOR(curr->device) != 01028 RSBAC_MAJOR(device)) 01029 || (RSBAC_MINOR(curr->device) != 01030 RSBAC_MINOR(device)) 01031 ) 01032 ) 01033 curr = curr->next; 01034 if (curr) 01035 reg_head.curr = curr; 01036 else 01037 rsbac_pr_debug(lists, "Lookup of unknown list name %s " 01038 "on device %02u:%02u\n", name, 01039 RSBAC_MAJOR(device), 01040 RSBAC_MINOR(device)); 01041 } 01042 /* it is the current item -> return it */ 01043 return curr; 01044 }
static int read_list | ( | struct rsbac_list_reg_item_t * | list | ) | [static] |
Definition at line 3268 of file gen_lists.c.
References rsbac_list_reg_item_t::device, rsbac_list_reg_item_t::dirty, do_read_list(), rsbac_list_reg_item_t::flags, name, rsbac_list_reg_item_t::name, rsbac_list_reg_item_t::old_name_base, RSBAC_ENOTFOUND, RSBAC_LIST_MAX_OLD_HASH, RSBAC_LIST_NO_MAX, RSBAC_MAXNAMELEN, rsbac_printk(), and TRUE.
Referenced by rsbac_list_register_hashed().
03269 { 03270 int res; 03271 u_int flags; 03272 03273 flags = list->flags; 03274 list->flags |= RSBAC_LIST_NO_MAX; 03275 res = do_read_list(list, list->name); 03276 if((res == -RSBAC_ENOTFOUND) && list->old_name_base[0]) { 03277 char name[RSBAC_MAXNAMELEN]; 03278 int i; 03279 03280 rsbac_printk(KERN_INFO "read_list(): list %s on device %02u:%02u not found, trying numbered lists 0 to %u with old name base '%s'\n", 03281 list->name, MAJOR(list->device), MINOR(list->device), RSBAC_LIST_MAX_OLD_HASH-1, list->old_name_base); 03282 for (i=0; i<RSBAC_LIST_MAX_OLD_HASH; i++) { 03283 sprintf(name, "%s%u", list->old_name_base, i); 03284 res = do_read_list(list, name); 03285 if(res && (res != -RSBAC_ENOTFOUND)) 03286 return res; 03287 } 03288 list->dirty = TRUE; 03289 } 03290 list->flags = flags; 03291 return res; 03292 }
static int read_lol_list | ( | struct rsbac_list_lol_reg_item_t * | list | ) | [static] |
Definition at line 3729 of file gen_lists.c.
References rsbac_list_lol_reg_item_t::device, rsbac_list_lol_reg_item_t::dirty, do_read_lol_list(), rsbac_list_lol_reg_item_t::flags, name, rsbac_list_lol_reg_item_t::name, rsbac_list_lol_reg_item_t::old_name_base, RSBAC_ENOTFOUND, RSBAC_LIST_LOL_MAX_OLD_HASH, RSBAC_LIST_NO_MAX, RSBAC_MAXNAMELEN, rsbac_printk(), and TRUE.
Referenced by rsbac_list_lol_register_hashed().
03730 { 03731 int res; 03732 u_int flags; 03733 03734 flags = list->flags; 03735 list->flags |= RSBAC_LIST_NO_MAX; 03736 res = do_read_lol_list(list, list->name); 03737 if((res == -RSBAC_ENOTFOUND) && list->old_name_base[0]) { 03738 char name[RSBAC_MAXNAMELEN]; 03739 int i; 03740 03741 rsbac_printk(KERN_INFO "read_lol_list(): list %s on device %02u:%02u not found, trying numbered lists 0 to %u with old name base '%s'\n", 03742 list->name, MAJOR(list->device), MINOR(list->device), RSBAC_LIST_LOL_MAX_OLD_HASH-1, list->old_name_base); 03743 for (i=0; i<RSBAC_LIST_LOL_MAX_OLD_HASH; i++) { 03744 sprintf(name, "%s%u", list->old_name_base, i); 03745 res = do_read_lol_list(list, name); 03746 if(res && (res != -RSBAC_ENOTFOUND)) 03747 return res; 03748 } 03749 list->dirty = TRUE; 03750 } 03751 list->flags = flags; 03752 return res; 03753 }
static void remove_all_items | ( | struct rsbac_list_reg_item_t * | list, | |
u_int | hash | |||
) | [static] |
Definition at line 2453 of file gen_lists.c.
References rsbac_list_hashed_t::count, rsbac_list_hashed_t::curr, rsbac_list_reg_item_t::hashed, rsbac_list_hashed_t::head, rsbac_list_item_t::next, NULL, rsbac_kfree(), and rsbac_list_hashed_t::tail.
Referenced by clear_reg().
02454 { 02455 struct rsbac_list_item_t *item_p; 02456 struct rsbac_list_item_t *next_item_p; 02457 02458 /* cleanup all items */ 02459 item_p = list->hashed[hash].head; 02460 while (item_p) { 02461 next_item_p = item_p->next; 02462 rsbac_kfree(item_p); 02463 item_p = next_item_p; 02464 } 02465 list->hashed[hash].head = NULL; 02466 list->hashed[hash].tail = NULL; 02467 list->hashed[hash].curr = NULL; 02468 list->hashed[hash].count = 0; 02469 }
static void remove_all_lol_items | ( | struct rsbac_list_lol_reg_item_t * | list, | |
u_int | hash | |||
) | [static] |
Definition at line 2782 of file gen_lists.c.
References rsbac_list_lol_hashed_t::count, rsbac_list_lol_hashed_t::curr, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_item_t::head, rsbac_list_lol_hashed_t::head, rsbac_list_lol_item_t::next, rsbac_list_item_t::next, NULL, rsbac_kfree(), and rsbac_list_lol_hashed_t::tail.
Referenced by clear_lol_reg().
02783 { 02784 struct rsbac_list_lol_item_t *item_p; 02785 struct rsbac_list_lol_item_t *next_item_p; 02786 struct rsbac_list_item_t *subitem_p; 02787 struct rsbac_list_item_t *next_subitem_p; 02788 02789 /* cleanup all items */ 02790 item_p = list->hashed[hash].head; 02791 while (item_p) { 02792 /* first remove subitems */ 02793 subitem_p = item_p->head; 02794 while (subitem_p) { 02795 next_subitem_p = subitem_p->next; 02796 rsbac_kfree(subitem_p); 02797 subitem_p = next_subitem_p; 02798 } 02799 next_item_p = item_p->next; 02800 rsbac_kfree(item_p); 02801 item_p = next_item_p; 02802 } 02803 list->hashed[hash].head = NULL; 02804 list->hashed[hash].tail = NULL; 02805 list->hashed[hash].curr = NULL; 02806 list->hashed[hash].count = 0; 02807 }
static void remove_all_lol_subitems | ( | struct rsbac_list_lol_item_t * | sublist | ) | [static] |
Definition at line 2764 of file gen_lists.c.
References rsbac_list_lol_item_t::count, rsbac_list_lol_item_t::curr, rsbac_list_lol_item_t::head, rsbac_list_item_t::next, NULL, rsbac_kfree(), and rsbac_list_lol_item_t::tail.
Referenced by rsbac_ta_list_lol_subremove_all().
02765 { 02766 struct rsbac_list_item_t *subitem_p; 02767 struct rsbac_list_item_t *next_subitem_p; 02768 02769 /* cleanup all items */ 02770 subitem_p = sublist->head; 02771 while (subitem_p) { 02772 next_subitem_p = subitem_p->next; 02773 rsbac_kfree(subitem_p); 02774 subitem_p = next_subitem_p; 02775 } 02776 sublist->head = NULL; 02777 sublist->tail = NULL; 02778 sublist->curr = NULL; 02779 sublist->count = 0; 02780 }
static void remove_item | ( | struct rsbac_list_reg_item_t * | list, | |
void * | desc | |||
) | [static] |
Definition at line 2438 of file gen_lists.c.
References do_remove_item(), rsbac_list_reg_item_t::hash_function, lookup_item(), and rsbac_list_reg_item_t::nr_hashes.
02439 { 02440 struct rsbac_list_item_t *item_p; 02441 u_int hash = 0; 02442 02443 if (!list || !desc) 02444 return; 02445 if(list->hash_function) 02446 hash = list->hash_function(desc, list->nr_hashes); 02447 /* first we must locate the item. */ 02448 if ((item_p = lookup_item(list, desc))) { 02449 do_remove_item(list, item_p, hash); 02450 } 02451 }
static void remove_lol_item | ( | struct rsbac_list_lol_reg_item_t * | list, | |
void * | desc | |||
) | [static] |
Definition at line 2657 of file gen_lists.c.
References do_remove_lol_item(), rsbac_list_lol_reg_item_t::hash_function, lookup_lol_item(), and rsbac_list_lol_reg_item_t::nr_hashes.
Referenced by rsbac_ta_list_lol_remove(), and rsbac_ta_list_lol_subadd_ttl().
02659 { 02660 struct rsbac_list_lol_item_t *item_p; 02661 u_int hash = 0; 02662 02663 if (!list || !desc) 02664 return; 02665 02666 if(list->hash_function) 02667 hash = list->hash_function(desc, list->nr_hashes); 02668 /* first we must locate the item. */ 02669 if ((item_p = lookup_lol_item(list, desc))) { 02670 do_remove_lol_item(list, item_p, hash); 02671 } 02672 }
static void remove_lol_reg | ( | struct rsbac_list_lol_reg_item_t * | handle | ) | [static] |
Definition at line 2922 of file gen_lists.c.
References clear_lol_reg(), rsbac_list_lol_reg_head_t::count, rsbac_list_lol_reg_head_t::curr, handle, rsbac_list_lol_reg_head_t::head, lol_reg_head, lookup_lol_reg(), rsbac_list_lol_reg_item_t::next, NULL, rsbac_list_lol_reg_item_t::prev, rsbac_list_lol_reg_item_t::self, and rsbac_list_lol_reg_head_t::tail.
Referenced by rsbac_list_lol_destroy(), and rsbac_list_lol_detach().
02923 { 02924 struct rsbac_list_lol_reg_item_t *item_p; 02925 02926 /* first we must locate the item. */ 02927 if ((item_p = lookup_lol_reg(handle))) { /* ok, item was found */ 02928 /* protect against reuse */ 02929 item_p->self = NULL; 02930 if ((lol_reg_head.head == item_p)) { /* item is head */ 02931 if ((lol_reg_head.tail == item_p)) { /* item is head and tail = only item -> list will be empty */ 02932 lol_reg_head.head = NULL; 02933 lol_reg_head.tail = NULL; 02934 } else { /* item is head, but not tail -> next item becomes head */ 02935 item_p->next->prev = NULL; 02936 lol_reg_head.head = item_p->next; 02937 }; 02938 } else { /* item is not head */ 02939 if ((lol_reg_head.tail == item_p)) { /*item is not head, but tail -> previous item becomes tail */ 02940 item_p->prev->next = NULL; 02941 lol_reg_head.tail = item_p->prev; 02942 } else { /* item is neither head nor tail -> item is cut out */ 02943 item_p->prev->next = item_p->next; 02944 item_p->next->prev = item_p->prev; 02945 } 02946 } 02947 02948 /* curr is no longer valid -> reset */ 02949 lol_reg_head.curr = NULL; 02950 /* adjust counter */ 02951 lol_reg_head.count--; 02952 /* now we can remove the item from memory */ 02953 clear_lol_reg(item_p); 02954 } /* end of if: item was found */ 02955 }
static void remove_lol_subitem | ( | struct rsbac_list_lol_reg_item_t * | list, | |
struct rsbac_list_lol_item_t * | sublist, | |||
void * | subdesc | |||
) | [static] |
Definition at line 2572 of file gen_lists.c.
References do_remove_lol_subitem(), and lookup_lol_subitem().
Referenced by rsbac_ta_list_lol_subremove(), and rsbac_ta_list_lol_subremove_from_all().
02575 { 02576 struct rsbac_list_item_t *item_p; 02577 02578 if (!list || !sublist || !subdesc) 02579 return; 02580 02581 /* first we must locate the item. */ 02582 if ((item_p = lookup_lol_subitem(list, sublist, subdesc))) { 02583 do_remove_lol_subitem(sublist, item_p); 02584 } 02585 }
static void remove_reg | ( | struct rsbac_list_reg_item_t * | handle | ) | [static] |
Definition at line 2863 of file gen_lists.c.
References clear_reg(), rsbac_list_reg_head_t::count, rsbac_list_reg_head_t::curr, handle, rsbac_list_reg_head_t::head, lookup_reg(), rsbac_list_reg_item_t::next, NULL, rsbac_list_reg_item_t::prev, reg_head, rsbac_list_reg_item_t::self, and rsbac_list_reg_head_t::tail.
Referenced by rsbac_list_destroy(), and rsbac_list_detach().
02864 { 02865 struct rsbac_list_reg_item_t *item_p; 02866 02867 /* first we must locate the item. */ 02868 if ((item_p = lookup_reg(handle))) { /* ok, item was found */ 02869 /* protect against reuse */ 02870 item_p->self = NULL; 02871 if ((reg_head.head == item_p)) { /* item is head */ 02872 if ((reg_head.tail == item_p)) { /* item is head and tail = only item -> list will be empty */ 02873 reg_head.head = NULL; 02874 reg_head.tail = NULL; 02875 } else { /* item is head, but not tail -> next item becomes head */ 02876 item_p->next->prev = NULL; 02877 reg_head.head = item_p->next; 02878 } 02879 } else { /* item is not head */ 02880 if ((reg_head.tail == item_p)) { /*item is not head, but tail -> previous item becomes tail */ 02881 item_p->prev->next = NULL; 02882 reg_head.tail = item_p->prev; 02883 } else { /* item is neither head nor tail -> item is cut out */ 02884 item_p->prev->next = item_p->next; 02885 item_p->next->prev = item_p->prev; 02886 } 02887 } 02888 02889 /* curr is no longer valid -> reset */ 02890 reg_head.curr = NULL; 02891 /* adjust counter */ 02892 reg_head.count--; 02893 /* now we can remove the item from memory */ 02894 clear_reg(item_p); 02895 } /* end of if: item was found */ 02896 }
int rsbac_check_lists | ( | int | correct | ) |
Definition at line 5255 of file gen_lists.c.
References rsbac_list_hashed_t::count, rsbac_list_info_t::data_size, rsbac_list_reg_item_t::def_data, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::device, do_remove_item(), rsbac_list_reg_item_t::hashed, rsbac_list_reg_head_t::head, rsbac_list_hashed_t::head, rsbac_list_reg_item_t::info, list_initialized, rsbac_list_reg_head_t::lock, rsbac_list_reg_item_t::lock, rsbac_list_item_t::max_age, rsbac_list_reg_item_t::name, rsbac_list_item_t::next, rsbac_list_reg_item_t::nr_hashes, reg_head, RSBAC_ENOTINITIALIZED, rsbac_pr_debug, and rsbac_printk().
Referenced by rsbac_do_init(), and sys_rsbac_check().
05256 { 05257 struct rsbac_list_reg_item_t *list; 05258 struct rsbac_list_lol_reg_item_t *lol_list; 05259 struct rsbac_list_item_t *item_p; 05260 struct rsbac_list_item_t *next_item_p; 05261 struct rsbac_list_lol_item_t *lol_item_p; 05262 struct rsbac_list_lol_item_t *next_lol_item_p; 05263 struct rsbac_list_item_t *lol_subitem_p; 05264 struct rsbac_list_item_t *next_lol_subitem_p; 05265 u_long lock_flags, rlock_flags; 05266 u_long tmp_count; 05267 u_long tmp_subcount; 05268 u_long subitem_count; 05269 u_long dirty = 0; 05270 int i; 05271 u_long all_count; 05272 05273 rsbac_pr_debug(lists, "called.\n"); 05274 if (!list_initialized) 05275 return -RSBAC_ENOTINITIALIZED; 05276 rsbac_read_lock(®_head.lock, &rlock_flags); 05277 list = reg_head.head; 05278 while (list) { 05279 /* check list */ 05280 rsbac_write_lock(&list->lock, &lock_flags); 05281 all_count = 0; 05282 for (i=0; i<list->nr_hashes; i++) { 05283 tmp_count = 0; 05284 item_p = list->hashed[i].head; 05285 while (item_p) { 05286 if ((item_p->max_age 05287 && (item_p->max_age <= RSBAC_CURRENT_TIME) 05288 ) 05289 || (list->def_data 05290 && !memcmp(((char *) item_p) + 05291 sizeof(*item_p) + 05292 list->info.desc_size, 05293 list->def_data, 05294 list->info.data_size) 05295 ) 05296 ) { 05297 next_item_p = item_p->next; 05298 do_remove_item(list, item_p, i); 05299 item_p = next_item_p; 05300 } else { 05301 tmp_count++; 05302 item_p = item_p->next; 05303 } 05304 } 05305 if (tmp_count != list->hashed[i].count) { 05306 if (correct) { 05307 rsbac_printk(KERN_WARNING "rsbac_check_lists(): correcting count mismatch for list %s hash %u on device %02u:%02u - was %u, counted %lu!\n", 05308 list->name, i, 05309 RSBAC_MAJOR(list->device), 05310 RSBAC_MINOR(list->device), 05311 list->hashed[i].count, tmp_count); 05312 list->hashed[i].count = tmp_count; 05313 } else { 05314 rsbac_printk(KERN_WARNING "rsbac_check_lists(): count mismatch for list %s hash %u on device %02u:%02u - is %u, counted %lu!\n", 05315 list->name, i, 05316 RSBAC_MAJOR(list->device), 05317 RSBAC_MINOR(list->device), 05318 list->hashed[i].count, tmp_count); 05319 } 05320 } 05321 all_count += list->hashed[i].count; 05322 } 05323 rsbac_write_unlock(&list->lock, &lock_flags); 05324 if (list->dirty && (list->flags & RSBAC_LIST_PERSIST)) { 05325 dirty++; 05326 rsbac_pr_debug(lists, "%s on %02u:%02u has %u items (list is dirty)\n", 05327 list->name, RSBAC_MAJOR(list->device), 05328 RSBAC_MINOR(list->device), all_count); 05329 } else 05330 rsbac_pr_debug(lists, "%s on %02u:%02u has %u items\n", 05331 list->name, RSBAC_MAJOR(list->device), 05332 RSBAC_MINOR(list->device), all_count); 05333 list = list->next; 05334 } 05335 rsbac_read_unlock(®_head.lock, &rlock_flags); 05336 05337 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 05338 lol_list = lol_reg_head.head; 05339 while (lol_list) { 05340 /* check list */ 05341 rsbac_write_lock(&lol_list->lock, &lock_flags); 05342 all_count = 0; 05343 subitem_count = 0; 05344 for (i=0; i<lol_list->nr_hashes; i++) { 05345 tmp_count = 0; 05346 lol_item_p = lol_list->hashed[i].head; 05347 while (lol_item_p) { 05348 tmp_subcount = 0; 05349 lol_subitem_p = lol_item_p->head; 05350 while (lol_subitem_p) { 05351 if ((lol_subitem_p->max_age 05352 && (lol_subitem_p->max_age <= 05353 RSBAC_CURRENT_TIME) 05354 ) 05355 || (lol_list->def_subdata 05356 && 05357 !memcmp(((char *) 05358 lol_subitem_p) + 05359 sizeof 05360 (*lol_subitem_p) + 05361 lol_list->info. 05362 subdesc_size, 05363 lol_list-> 05364 def_subdata, 05365 lol_list->info. 05366 subdata_size) 05367 ) 05368 ) { 05369 next_lol_subitem_p = 05370 lol_subitem_p->next; 05371 do_remove_lol_subitem 05372 (lol_item_p, 05373 lol_subitem_p); 05374 lol_subitem_p = 05375 next_lol_subitem_p; 05376 } else { 05377 tmp_subcount++; 05378 lol_subitem_p = 05379 lol_subitem_p->next; 05380 } 05381 } 05382 if (tmp_subcount != lol_item_p->count) { 05383 if (correct) { 05384 rsbac_printk(KERN_WARNING "rsbac_check_lists(): correcting count mismatch for list of lists %s hash %u sublist on %02u:%02u - was %lu, counted %lu!\n", 05385 lol_list->name, i, 05386 RSBAC_MAJOR 05387 (lol_list-> 05388 device), 05389 RSBAC_MINOR 05390 (lol_list-> 05391 device), 05392 lol_item_p-> 05393 count, 05394 tmp_subcount); 05395 lol_item_p->count = 05396 tmp_subcount; 05397 } else { 05398 rsbac_printk(KERN_WARNING "rsbac_check_lists(): count mismatch for list of lists %s hash %u sublist on %02u:%02u - is %lu, counted %lu!\n", 05399 lol_list->name, i, 05400 RSBAC_MAJOR 05401 (lol_list-> 05402 device), 05403 RSBAC_MINOR 05404 (lol_list-> 05405 device), 05406 lol_item_p-> 05407 count, 05408 tmp_subcount); 05409 } 05410 } 05411 if ((lol_item_p->max_age 05412 && (lol_item_p->max_age <= RSBAC_CURRENT_TIME) 05413 ) 05414 || (lol_list->def_data 05415 && !lol_item_p->count 05416 && !memcmp(((char *) lol_item_p) + 05417 sizeof(*lol_item_p) + 05418 lol_list->info.desc_size, 05419 lol_list->def_data, 05420 lol_list->info.data_size) 05421 ) 05422 || (!lol_list->info.data_size 05423 && (lol_list->flags & RSBAC_LIST_DEF_DATA) 05424 && !lol_item_p->count) 05425 ) { 05426 next_lol_item_p = lol_item_p->next; 05427 do_remove_lol_item(lol_list, lol_item_p, i); 05428 lol_item_p = next_lol_item_p; 05429 } else { 05430 tmp_count++; 05431 subitem_count += lol_item_p->count; 05432 lol_item_p = lol_item_p->next; 05433 } 05434 } 05435 if (tmp_count != lol_list->hashed[i].count) { 05436 if (correct) { 05437 rsbac_printk(KERN_WARNING "rsbac_check_lists(): correcting count mismatch for list of lists %s hash %u on %02u:%02u - was %u, counted %lu!\n", 05438 lol_list->name, i, 05439 RSBAC_MAJOR(lol_list->device), 05440 RSBAC_MINOR(lol_list->device), 05441 lol_list->hashed[i].count, tmp_count); 05442 lol_list->hashed[i].count = tmp_count; 05443 } else { 05444 rsbac_printk(KERN_WARNING "rsbac_check_lists(): count mismatch for list of lists %s hash %u on %02u:%02u - is %u, counted %lu!\n", 05445 lol_list->name, i, 05446 RSBAC_MAJOR(lol_list->device), 05447 RSBAC_MINOR(lol_list->device), 05448 lol_list->hashed[i].count, tmp_count); 05449 } 05450 } 05451 all_count += lol_list->hashed[i].count; 05452 } 05453 rsbac_write_unlock(&lol_list->lock, &lock_flags); 05454 if (lol_list->dirty 05455 && (lol_list->flags & RSBAC_LIST_PERSIST)) { 05456 dirty++; 05457 rsbac_pr_debug(lists, "%s on %02u:%02u has %u items and %lu subitems (list is dirty)\n", 05458 lol_list->name, 05459 RSBAC_MAJOR(lol_list->device), 05460 RSBAC_MINOR(lol_list->device), 05461 all_count, subitem_count); 05462 } else 05463 rsbac_pr_debug(lists, "%s on %02u:%02u has %u items and %lu subitems\n", 05464 lol_list->name, 05465 RSBAC_MAJOR(lol_list->device), 05466 RSBAC_MINOR(lol_list->device), 05467 all_count, subitem_count); 05468 lol_list = lol_list->next; 05469 } 05470 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 05471 return 0; 05472 }
int rsbac_list_auto_rehash | ( | void | ) |
Definition at line 10528 of file gen_lists.c.
References rsbac_list_hashed_t::count, rsbac_list_reg_item_t::device, do_rehash(), rsbac_list_reg_item_t::flags, rsbac_list_reg_item_t::hashed, rsbac_list_reg_head_t::head, rsbac_list_reg_item_t::lock, rsbac_list_reg_head_t::lock, rsbac_list_reg_item_t::name, rsbac_list_reg_item_t::next, rsbac_list_reg_item_t::nr_hashes, reg_head, RSBAC_LIST_AUTO_HASH_RESIZE, RSBAC_LIST_AUTO_REHASH_TRIGGER, rsbac_list_max_hashes, and rsbac_printk().
10529 { 10530 int i; 10531 int err; 10532 struct rsbac_list_reg_item_t *list; 10533 struct rsbac_list_lol_reg_item_t *lol_list; 10534 u_long rlock_flags, lock_flags; 10535 long count; 10536 u_int nr_rehashed = 0; 10537 10538 rsbac_read_lock(®_head.lock, &rlock_flags); 10539 list = reg_head.head; 10540 while(list) { 10541 if((list->flags & RSBAC_LIST_AUTO_HASH_RESIZE) 10542 && (list->nr_hashes < rsbac_list_max_hashes)) { 10543 count = 0; 10544 for (i=0; i<list->nr_hashes; i++) { 10545 count += list->hashed[i].count; 10546 } 10547 if(count / list->nr_hashes > RSBAC_LIST_AUTO_REHASH_TRIGGER) { 10548 u_int new_nr; 10549 10550 new_nr = list->nr_hashes; 10551 while((new_nr < rsbac_list_max_hashes) 10552 && (count / new_nr > RSBAC_LIST_AUTO_REHASH_TRIGGER)) 10553 new_nr = new_nr << 1; 10554 if(new_nr > rsbac_list_max_hashes) 10555 new_nr = rsbac_list_max_hashes; 10556 rsbac_printk(KERN_INFO "rsbac_list_auto_rehash(): changing list %s hash size on device %02u:%02u from %u to %u\n", 10557 list->name, MAJOR(list->device), MINOR(list->device), list->nr_hashes, new_nr); 10558 rsbac_write_lock(&list->lock, &lock_flags); 10559 err = do_rehash(list, new_nr); 10560 rsbac_write_unlock(&list->lock, &lock_flags); 10561 if(!err) 10562 nr_rehashed++; 10563 else { 10564 rsbac_printk(KERN_WARNING "rsbac_list_auto_rehash(): changing list %s hash size on device %02u:%02u from %u to %u failed with error %i\n", 10565 list->name, MAJOR(list->device), MINOR(list->device), list->nr_hashes, new_nr, err); 10566 } 10567 } 10568 } 10569 list = list->next; 10570 } 10571 rsbac_read_unlock(®_head.lock, &rlock_flags); 10572 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 10573 lol_list = lol_reg_head.head; 10574 while(lol_list) { 10575 if((lol_list->flags & RSBAC_LIST_AUTO_HASH_RESIZE) 10576 && (lol_list->nr_hashes < rsbac_list_lol_max_hashes)) { 10577 count = 0; 10578 for (i=0; i<lol_list->nr_hashes; i++) { 10579 count += lol_list->hashed[i].count; 10580 } 10581 if(count / lol_list->nr_hashes > RSBAC_LIST_AUTO_REHASH_TRIGGER) { 10582 u_int new_nr; 10583 10584 new_nr = lol_list->nr_hashes; 10585 while((new_nr < rsbac_list_lol_max_hashes) 10586 && (count / new_nr > RSBAC_LIST_AUTO_REHASH_TRIGGER)) 10587 new_nr = new_nr << 1; 10588 if(new_nr > rsbac_list_lol_max_hashes) 10589 new_nr = rsbac_list_lol_max_hashes; 10590 rsbac_printk(KERN_INFO "rsbac_list_auto_rehash(): changing list of lists %s hash size on device %02u:%02u from %u to %u\n", 10591 lol_list->name, MAJOR(lol_list->device), MINOR(lol_list->device), lol_list->nr_hashes, new_nr); 10592 rsbac_write_lock(&lol_list->lock, &lock_flags); 10593 err = do_lol_rehash(lol_list, new_nr); 10594 rsbac_write_unlock(&lol_list->lock, &lock_flags); 10595 if(!err) 10596 nr_rehashed++; 10597 else { 10598 rsbac_printk(KERN_WARNING "rsbac_list_auto_rehash(): changing list of lists %s hash size on device %02u:%02u from %u to %u failed with error %i\n", 10599 lol_list->name, MAJOR(lol_list->device), MINOR(lol_list->device), lol_list->nr_hashes, new_nr, err); 10600 } 10601 } 10602 } 10603 lol_list = lol_list->next; 10604 } 10605 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 10606 10607 if(nr_rehashed > 0) 10608 rsbac_printk(KERN_INFO "rsbac_list_auto_rehash(): %u lists rehashed\n", 10609 nr_rehashed); 10610 return nr_rehashed; 10611 }
int rsbac_list_check | ( | rsbac_list_handle_t | handle, | |
int | correct | |||
) |
Definition at line 5477 of file gen_lists.c.
References rsbac_list_hashed_t::count, rsbac_list_info_t::data_size, rsbac_list_reg_item_t::def_data, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::device, rsbac_list_reg_item_t::dirty, do_remove_item(), rsbac_list_reg_item_t::hashed, rsbac_list_hashed_t::head, rsbac_list_reg_item_t::info, list_initialized, rsbac_list_reg_head_t::lock, rsbac_list_reg_item_t::lock, rsbac_list_item_t::max_age, rsbac_list_reg_item_t::name, rsbac_list_item_t::next, rsbac_list_reg_item_t::nr_hashes, reg_head, RSBAC_EINVALIDLIST, RSBAC_ENOTINITIALIZED, rsbac_pr_debug, rsbac_printk(), rsbac_list_reg_item_t::self, and TRUE.
05478 { 05479 struct rsbac_list_reg_item_t *list; 05480 struct rsbac_list_item_t *item_p; 05481 struct rsbac_list_item_t *next_item_p; 05482 u_long lock_flags; 05483 u_long rlock_flags; 05484 u_long tmp_count; 05485 int i; 05486 05487 if (!handle) 05488 return -RSBAC_EINVALIDLIST; 05489 if (!list_initialized) 05490 return -RSBAC_ENOTINITIALIZED; 05491 05492 list = (struct rsbac_list_reg_item_t *) handle; 05493 if (!list || (list->self != list)) 05494 return -RSBAC_EINVALIDLIST; 05495 05496 rsbac_read_lock(®_head.lock, &rlock_flags); 05497 rsbac_pr_debug(lists, "checking list %s.\n", list->name); 05498 rsbac_write_lock(&list->lock, &lock_flags); 05499 for (i=0; i<list->nr_hashes; i++) { 05500 tmp_count = 0; 05501 item_p = list->hashed[i].head; 05502 while (item_p) { 05503 if ((item_p->max_age 05504 && (item_p->max_age <= RSBAC_CURRENT_TIME) 05505 ) 05506 || (list->def_data 05507 && !memcmp(((char *) item_p) + sizeof(*item_p) + 05508 list->info.desc_size, list->def_data, 05509 list->info.data_size) 05510 ) 05511 ) { 05512 next_item_p = item_p->next; 05513 do_remove_item(list, item_p, i); 05514 item_p = next_item_p; 05515 list->dirty = TRUE; 05516 } else { 05517 tmp_count++; 05518 item_p = item_p->next; 05519 } 05520 } 05521 if (tmp_count != list->hashed[i].count) { 05522 if (correct) { 05523 rsbac_printk(KERN_WARNING "rsbac_list_check(): correcting count mismatch for list %s hash %u on device %02u:%02u - was %u, counted %lu!\n", 05524 list->name, i, RSBAC_MAJOR(list->device), 05525 RSBAC_MINOR(list->device), 05526 list->hashed[i].count, tmp_count); 05527 list->hashed[i].count = tmp_count; 05528 list->dirty = TRUE; 05529 } else { 05530 rsbac_printk(KERN_WARNING "rsbac_list_check(): count mismatch for list %s hash %u on device %02u:%02u - is %u, counted %lu!\n", 05531 list->name, i, RSBAC_MAJOR(list->device), 05532 RSBAC_MINOR(list->device), 05533 list->hashed[i].count, tmp_count); 05534 } 05535 } 05536 } 05537 rsbac_write_unlock(&list->lock, &lock_flags); 05538 rsbac_read_unlock(®_head.lock, &rlock_flags); 05539 return 0; 05540 }
int rsbac_list_compare_u32 | ( | void * | desc1, | |
void * | desc2 | |||
) |
Definition at line 4956 of file gen_lists.c.
04957 { 04958 if( *((__u32*) desc1) < *((__u32*) desc2)) 04959 return -1; 04960 return( *((__u32*) desc1) != *((__u32*) desc2)); 04961 }
long rsbac_list_copy | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | from_handle, | |||
rsbac_list_handle_t | to_handle | |||
) |
Definition at line 10185 of file gen_lists.c.
References rsbac_list_info_t::data_size, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::hashed, rsbac_list_reg_item_t::info, rsbac_list_reg_head_t::lock, rsbac_list_reg_item_t::lock, rsbac_list_reg_item_t::name, rsbac_list_reg_item_t::nr_hashes, reg_head, RSBAC_EBUSY, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, rsbac_pr_debug, rsbac_ta_list_exist(), and rsbac_list_reg_item_t::self.
10188 { 10189 struct rsbac_list_reg_item_t *from_list; 10190 struct rsbac_list_reg_item_t *to_list; 10191 struct rsbac_list_item_t *item_p; 10192 u_long rlock_flags, from_lock_flags, to_lock_flags; 10193 int i; 10194 int err = 0; 10195 10196 if (!from_handle || !to_handle) 10197 return -RSBAC_EINVALIDLIST; 10198 10199 from_list = (struct rsbac_list_reg_item_t *) from_handle; 10200 if (from_list->self != from_list) 10201 return -RSBAC_EINVALIDLIST; 10202 to_list = (struct rsbac_list_reg_item_t *) to_handle; 10203 if (to_list->self != to_list) 10204 return -RSBAC_EINVALIDLIST; 10205 if((from_list->info.desc_size != to_list->info.desc_size) 10206 || (from_list->info.data_size != to_list->info.data_size)) 10207 return -RSBAC_EINVALIDVALUE; 10208 10209 #ifdef CONFIG_RSBAC_LIST_TRANS 10210 if (ta_number) { 10211 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 10212 return -RSBAC_EINVALIDTRANSACTION; 10213 } 10214 #endif 10215 10216 rsbac_read_lock(®_head.lock, &rlock_flags); 10217 rsbac_pr_debug(lists, "list %s to list %s.\n", 10218 from_list->name, to_list->name); 10219 rsbac_read_lock(&from_list->lock, &from_lock_flags); 10220 rsbac_write_lock(&to_list->lock, &to_lock_flags); 10221 10222 #ifdef CONFIG_RSBAC_LIST_TRANS 10223 /* Check for other transactions at the target list */ 10224 if(ta_number) 10225 for (i=0; i<to_list->nr_hashes; i++) 10226 if(to_list->hashed[i].ta_copied != ta_number) { 10227 err = -RSBAC_EBUSY; 10228 goto out_unlock; 10229 } 10230 #endif 10231 for (i=0; i<to_list->nr_hashes; i++) { 10232 #ifdef CONFIG_RSBAC_LIST_TRANS 10233 if(ta_number && (to_list->hashed[i].ta_copied == ta_number)) 10234 ta_remove_all_items(to_list, i); 10235 else 10236 #endif 10237 remove_all_items(to_list, i); 10238 } 10239 for (i=0; i<from_list->nr_hashes; i++) { 10240 #ifdef CONFIG_RSBAC_LIST_TRANS 10241 if (ta_number) { 10242 if(from_list->hashed[i].ta_copied == ta_number) 10243 item_p = from_list->hashed[i].ta_head; 10244 else 10245 item_p = from_list->hashed[i].head; 10246 while(item_p) { 10247 if (!ta_add_item(ta_number, 10248 to_list, 10249 item_p->max_age, 10250 &item_p[1], 10251 &item_p[1] + from_list->info.desc_size)) { 10252 err = -RSBAC_EWRITEFAILED; 10253 goto out_unlock; 10254 } 10255 item_p = item_p->next; 10256 } 10257 } 10258 else 10259 #endif 10260 { 10261 item_p = from_list->hashed[i].head; 10262 while(item_p) { 10263 if (!add_item(to_list, 10264 item_p->max_age, 10265 &item_p[1], 10266 &item_p[1] + from_list->info.desc_size)) { 10267 err = -RSBAC_EWRITEFAILED; 10268 goto out_unlock; 10269 } 10270 item_p = item_p->next; 10271 } 10272 } 10273 } 10274 10275 out_unlock: 10276 rsbac_write_unlock(&to_list->lock, &to_lock_flags); 10277 rsbac_read_unlock(&from_list->lock, &from_lock_flags); 10278 rsbac_read_unlock(®_head.lock, &rlock_flags); 10279 return err; 10280 }
int rsbac_list_destroy | ( | rsbac_list_handle_t * | handle_p, | |
rsbac_list_key_t | key | |||
) |
Definition at line 6106 of file gen_lists.c.
References rsbac_list_reg_item_t::flags, rsbac_list_reg_item_t::info, rsbac_list_info_t::key, list_initialized, rsbac_list_reg_head_t::lock, lookup_reg(), rsbac_list_reg_item_t::name, NULL, proc_rsbac_backup_p, reg_head, remove_reg(), RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_ENOTINITIALIZED, RSBAC_LIST_BACKUP, rsbac_pr_debug, and rsbac_printk().
06108 { 06109 struct rsbac_list_reg_item_t *reg_item_p; 06110 u_long lock_flags; 06111 int err = 0; 06112 06113 if (!handle_p) 06114 return -RSBAC_EINVALIDPOINTER; 06115 if (!*handle_p) 06116 return -RSBAC_EINVALIDLIST; 06117 if (!list_initialized) 06118 return -RSBAC_ENOTINITIALIZED; 06119 06120 rsbac_write_lock(®_head.lock, &lock_flags); 06121 reg_item_p = 06122 lookup_reg((struct rsbac_list_reg_item_t *) *handle_p); 06123 if (!reg_item_p) { 06124 rsbac_write_unlock(®_head.lock, &lock_flags); 06125 rsbac_printk(KERN_WARNING "rsbac_list_destroy: destroying list failed due to invalid handle!\n"); 06126 return -RSBAC_EINVALIDLIST; 06127 } 06128 if (reg_item_p->info.key != key) { 06129 rsbac_write_unlock(®_head.lock, &lock_flags); 06130 rsbac_printk(KERN_WARNING "rsbac_list_destroy: destroying list %s denied due to invalid key!\n", 06131 reg_item_p->name); 06132 return -EPERM; 06133 } 06134 rsbac_pr_debug(lists, "destroying list %s.\n", 06135 reg_item_p->name); 06136 #if defined(CONFIG_RSBAC_PROC) 06137 /* delete proc entry, if it exists */ 06138 if ((reg_item_p->flags & RSBAC_LIST_BACKUP) 06139 && reg_item_p->proc_entry_p) { 06140 remove_proc_entry(reg_item_p->name, proc_rsbac_backup_p); 06141 reg_item_p->proc_entry_p = NULL; 06142 } 06143 #endif 06144 06145 #if 0 06146 if (reg_item_p->flags & RSBAC_LIST_PERSIST) 06147 err = unlink_list(reg_item_p); 06148 #endif 06149 06150 remove_reg(reg_item_p); 06151 *handle_p = NULL; 06152 rsbac_write_unlock(®_head.lock, &lock_flags); 06153 return err; 06154 }
int rsbac_list_detach | ( | rsbac_list_handle_t * | handle_p, | |
rsbac_list_key_t | key | |||
) |
Definition at line 6213 of file gen_lists.c.
References rsbac_list_write_head_t::count, rsbac_list_reg_item_t::dirty, FALSE, fill_buffer(), rsbac_list_reg_item_t::flags, rsbac_list_write_head_t::head, rsbac_list_reg_item_t::info, rsbac_list_info_t::key, list_initialized, rsbac_list_reg_head_t::lock, lookup_reg(), rsbac_list_reg_item_t::name, rsbac_list_reg_item_t::no_write, NULL, proc_rsbac_backup_p, reg_head, remove_reg(), RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_ENOTINITIALIZED, RSBAC_ENOTWRITABLE, RSBAC_LIST_BACKUP, rsbac_list_write_buffers(), rsbac_printk(), rsbac_list_write_head_t::tail, and TRUE.
Referenced by aci_detach_fd_lists(), cleanup_module(), and init_module().
06214 { 06215 struct rsbac_list_reg_item_t *reg_item_p; 06216 u_long lock_flags; 06217 int err = 0; 06218 06219 if (!handle_p) 06220 return -RSBAC_EINVALIDPOINTER; 06221 if (!*handle_p) 06222 return -RSBAC_EINVALIDLIST; 06223 if (!list_initialized) 06224 return -RSBAC_ENOTINITIALIZED; 06225 06226 rsbac_read_lock(®_head.lock, &lock_flags); 06227 reg_item_p = 06228 lookup_reg((struct rsbac_list_reg_item_t *) *handle_p); 06229 if (!reg_item_p) { 06230 rsbac_read_unlock(®_head.lock, &lock_flags); 06231 rsbac_printk(KERN_WARNING "rsbac_list_detach: detaching list failed due to invalid handle!\n"); 06232 return -RSBAC_EINVALIDLIST; 06233 } 06234 if (reg_item_p->info.key != key) { 06235 rsbac_read_unlock(®_head.lock, &lock_flags); 06236 rsbac_printk(KERN_WARNING "rsbac_list_detach: detaching list %s denied due to invalid key %u!\n", 06237 reg_item_p->name, key); 06238 return -EPERM; 06239 } 06240 #if defined(CONFIG_RSBAC_PROC) 06241 /* delete proc entry, if it exists */ 06242 if ((reg_item_p->flags & RSBAC_LIST_BACKUP) 06243 && reg_item_p->proc_entry_p) { 06244 remove_proc_entry(reg_item_p->name, proc_rsbac_backup_p); 06245 reg_item_p->proc_entry_p = NULL; 06246 } 06247 #endif 06248 #ifndef CONFIG_RSBAC_NO_WRITE 06249 /* final write, if dirty etc. */ 06250 if ((reg_item_p->flags & RSBAC_LIST_PERSIST) 06251 && reg_item_p->dirty && !reg_item_p->no_write) { 06252 struct rsbac_list_write_head_t write_head; 06253 struct rsbac_list_write_item_t *write_item_p; 06254 06255 reg_item_p->dirty = FALSE; 06256 err = fill_buffer(reg_item_p, &write_item_p); 06257 if (!err) { 06258 write_head.head = write_item_p; 06259 write_head.tail = write_item_p; 06260 write_head.count = 1; 06261 rsbac_read_unlock(®_head.lock, &lock_flags); 06262 rsbac_list_write_buffers(write_head, TRUE); 06263 } else { 06264 rsbac_read_unlock(®_head.lock, &lock_flags); 06265 if (err != -RSBAC_ENOTWRITABLE) { 06266 rsbac_printk(KERN_WARNING "rsbac_list_detach(): fill_buffer() for list %s returned error %i\n", 06267 reg_item_p->name, err); 06268 } 06269 } 06270 } else 06271 rsbac_read_unlock(®_head.lock, &lock_flags); 06272 #else 06273 rsbac_read_unlock(®_head.lock, &lock_flags); 06274 #endif 06275 /* disable handle */ 06276 *handle_p = NULL; 06277 /* too bad that the list might have been changed again - we do not care anymore */ 06278 rsbac_write_lock(®_head.lock, &lock_flags); 06279 remove_reg(reg_item_p); 06280 rsbac_write_unlock(®_head.lock, &lock_flags); 06281 return err; 06282 }
int rsbac_list_get_item_size | ( | rsbac_list_handle_t | handle | ) |
Definition at line 9737 of file gen_lists.c.
References rsbac_list_info_t::data_size, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::info, list_initialized, RSBAC_EINVALIDLIST, RSBAC_ENOTINITIALIZED, and rsbac_list_reg_item_t::self.
09738 { 09739 struct rsbac_list_reg_item_t *list; 09740 09741 if (!handle) 09742 return -RSBAC_EINVALIDLIST; 09743 if (!list_initialized) 09744 return -RSBAC_ENOTINITIALIZED; 09745 09746 list = (struct rsbac_list_reg_item_t *) handle; 09747 if (list->self != list) 09748 return -RSBAC_EINVALIDLIST; 09749 return list->info.desc_size + list->info.data_size; 09750 }
long rsbac_list_get_nr_hashes | ( | rsbac_list_handle_t | handle | ) |
Definition at line 10616 of file gen_lists.c.
References list_initialized, rsbac_list_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, RSBAC_ENOTINITIALIZED, and rsbac_list_reg_item_t::self.
10617 { 10618 struct rsbac_list_reg_item_t *list; 10619 10620 if (!handle) 10621 return -RSBAC_EINVALIDLIST; 10622 if (!list_initialized) 10623 return -RSBAC_ENOTINITIALIZED; 10624 10625 list = (struct rsbac_list_reg_item_t *) handle; 10626 if (list->self != list) 10627 return -RSBAC_EINVALIDLIST; 10628 10629 return list->nr_hashes; 10630 }
u_int rsbac_list_hash_dev | ( | void * | desc, | |
__u32 | nr_hashes | |||
) |
Definition at line 10158 of file gen_lists.c.
Referenced by register_dev_lists(), and rsbac_init_acl().
10159 { 10160 return ( ( ((struct rsbac_dev_desc_t *) desc)->major 10161 + ((struct rsbac_dev_desc_t *) desc)->minor ) 10162 & (nr_hashes - 1)); 10163 }
u_int rsbac_list_hash_fd | ( | void * | desc, | |
__u32 | nr_hashes | |||
) |
Definition at line 10118 of file gen_lists.c.
Referenced by acl_register_fd_lists(), auth_register_fd_lists(), mac_register_fd_lists(), and register_fd_lists().
10119 { 10120 return (*((rsbac_inode_nr_t *) desc) & (nr_hashes - 1)); 10121 }
u_int rsbac_list_hash_gid | ( | void * | desc, | |
__u32 | nr_hashes | |||
) |
Definition at line 10142 of file gen_lists.c.
Referenced by rsbac_init_acl(), and rsbac_init_um().
10143 { 10144 return (*((rsbac_gid_t *) desc) & (nr_hashes - 1)); 10145 }
u_int rsbac_list_hash_ipc | ( | void * | desc, | |
__u32 | nr_hashes | |||
) |
Definition at line 10150 of file gen_lists.c.
Referenced by register_ipc_lists().
10151 { 10152 return (((struct rsbac_ipc_t *) desc)->id.id_nr & (nr_hashes - 1)); 10153 }
u_int rsbac_list_hash_netobj | ( | void * | desc, | |
__u32 | nr_hashes | |||
) |
Definition at line 10176 of file gen_lists.c.
Referenced by rsbac_init_acl().
10177 { 10178 return (*((__u32 *) desc) & (nr_hashes - 1)); 10179 }
u_int rsbac_list_hash_nettemp | ( | void * | desc, | |
__u32 | nr_hashes | |||
) |
Definition at line 10168 of file gen_lists.c.
Referenced by rsbac_init_acl().
10169 { 10170 return (*((rsbac_net_temp_id_t *) desc) & (nr_hashes - 1)); 10171 }
u_int rsbac_list_hash_pid | ( | void * | desc, | |
__u32 | nr_hashes | |||
) |
Definition at line 10126 of file gen_lists.c.
Referenced by register_process_lists(), and rsbac_init_auth().
10127 { 10128 return (*((rsbac_pid_t *) desc) & (nr_hashes - 1)); 10129 }
u_int rsbac_list_hash_u32 | ( | void * | desc, | |
__u32 | nr_hashes | |||
) |
Definition at line 10110 of file gen_lists.c.
10111 { 10112 return (*((__u32 *) desc) & (nr_hashes - 1)); 10113 }
u_int rsbac_list_hash_uid | ( | void * | desc, | |
__u32 | nr_hashes | |||
) |
Definition at line 10134 of file gen_lists.c.
Referenced by register_user_lists1(), register_user_lists2(), rsbac_init_acl(), and rsbac_init_um().
10135 { 10136 return (*((rsbac_uid_t *) desc) & (nr_hashes - 1)); 10137 }
int __init rsbac_list_init | ( | void | ) |
Definition at line 4966 of file gen_lists.c.
References rsbac_list_reg_head_t::count, rsbac_list_lol_reg_head_t::count, rsbac_list_reg_head_t::curr, rsbac_list_lol_reg_head_t::curr, get_error_name(), rsbac_list_reg_head_t::head, rsbac_list_lol_reg_head_t::head, list_initialized, rsbac_list_reg_head_t::lock, rsbac_list_lol_reg_head_t::lock, lol_reg_head, NULL, proc_rsbac_root_p, reg_head, RSBAC_LIST_COUNTS_PROC_NAME, rsbac_list_lol_max_hashes, rsbac_list_max_hashes, RSBAC_LIST_MIN_MAX_HASHES, RSBAC_LIST_PROC_NAME, rsbac_list_register(), RSBAC_LIST_TA_KEY, RSBAC_LIST_VERSION, RSBAC_MAX_KMALLOC, RSBAC_MAXNAMELEN, rsbac_printk(), rsbac_list_reg_head_t::tail, rsbac_list_lol_reg_head_t::tail, and TRUE.
Referenced by rsbac_do_init().
04968 { 04969 #if defined(CONFIG_RSBAC_LIST_TRANS) || defined(CONFIG_RSBAC_LIST_REPL) 04970 int err; 04971 struct rsbac_list_info_t *list_info_p; 04972 #endif 04973 u_int i; 04974 04975 reg_head.head = NULL; 04976 reg_head.tail = NULL; 04977 reg_head.curr = NULL; 04978 reg_head.lock = RW_LOCK_UNLOCKED; 04979 reg_head.count = 0; 04980 04981 lol_reg_head.head = NULL; 04982 lol_reg_head.tail = NULL; 04983 lol_reg_head.curr = NULL; 04984 lol_reg_head.lock = RW_LOCK_UNLOCKED; 04985 lol_reg_head.count = 0; 04986 04987 /* Check that the rsbac_list_max_hashes is correct 04988 * and a potential of 2, else correct it 04989 */ 04990 if(CONFIG_RSBAC_LIST_MAX_HASHES < RSBAC_LIST_MIN_MAX_HASHES) 04991 rsbac_list_max_hashes = RSBAC_LIST_MIN_MAX_HASHES; 04992 else if (CONFIG_RSBAC_LIST_MAX_HASHES > RSBAC_MAX_KMALLOC / sizeof(struct rsbac_list_hashed_t)) 04993 rsbac_list_max_hashes = RSBAC_MAX_KMALLOC / sizeof(struct rsbac_list_hashed_t); 04994 else 04995 rsbac_list_max_hashes = CONFIG_RSBAC_LIST_MAX_HASHES; 04996 04997 i = 1; 04998 while ((i << 1) <= rsbac_list_max_hashes) 04999 i = i << 1; 05000 rsbac_list_max_hashes = i; 05001 05002 /* Also for rsbac_list_lol_max_hashes */ 05003 if(CONFIG_RSBAC_LIST_MAX_HASHES < RSBAC_LIST_MIN_MAX_HASHES) 05004 rsbac_list_lol_max_hashes = RSBAC_LIST_MIN_MAX_HASHES; 05005 else if (CONFIG_RSBAC_LIST_MAX_HASHES > RSBAC_MAX_KMALLOC / sizeof(struct rsbac_list_lol_hashed_t)) 05006 rsbac_list_lol_max_hashes = RSBAC_MAX_KMALLOC / sizeof(struct rsbac_list_lol_hashed_t); 05007 else 05008 rsbac_list_lol_max_hashes = CONFIG_RSBAC_LIST_MAX_HASHES; 05009 05010 i = 1; 05011 while ((i << 1) <= rsbac_list_lol_max_hashes) 05012 i = i << 1; 05013 rsbac_list_lol_max_hashes = i; 05014 05015 list_initialized = TRUE; 05016 05017 #if defined(CONFIG_RSBAC_LIST_TRANS) || defined(CONFIG_RSBAC_LIST_REPL) 05018 list_info_p = kmalloc(sizeof(*list_info_p), GFP_KERNEL); 05019 if (!list_info_p) { 05020 return -ENOMEM; 05021 } 05022 #endif 05023 05024 /* init proc entry */ 05025 #if defined(CONFIG_RSBAC_PROC) 05026 { 05027 struct proc_dir_entry *tmp_entry_p; 05028 05029 tmp_entry_p = create_proc_entry(RSBAC_LIST_PROC_NAME, 05030 S_IFREG | S_IRUGO, 05031 proc_rsbac_root_p); 05032 if (tmp_entry_p) { 05033 tmp_entry_p->get_info = lists_proc_info; 05034 } 05035 tmp_entry_p = create_proc_entry(RSBAC_LIST_COUNTS_PROC_NAME, 05036 S_IFREG | S_IRUGO, 05037 proc_rsbac_root_p); 05038 if (tmp_entry_p) { 05039 tmp_entry_p->get_info = lists_counts_proc_info; 05040 } 05041 } 05042 #endif 05043 05044 #ifdef CONFIG_RSBAC_LIST_TRANS 05045 rsbac_printk(KERN_INFO "rsbac_list_init(): Registering transaction list.\n"); 05046 list_info_p->version = 1; 05047 list_info_p->key = RSBAC_LIST_TA_KEY; 05048 list_info_p->desc_size = sizeof(rsbac_list_ta_number_t); 05049 list_info_p->data_size = sizeof(struct rsbac_list_ta_data_t); 05050 list_info_p->max_age = 0; 05051 err = rsbac_list_register(RSBAC_LIST_VERSION, 05052 (void **) &ta_handle, 05053 list_info_p, 05054 0, 05055 NULL, 05056 NULL, 05057 NULL, "transactions", RSBAC_AUTO_DEV); 05058 if (err) { 05059 char *tmp = kmalloc(RSBAC_MAXNAMELEN, GFP_KERNEL); 05060 05061 if (tmp) { 05062 rsbac_printk(KERN_WARNING "rsbac_list_init(): Registering transaction list failed with error %s\n", 05063 get_error_name(tmp, err)); 05064 kfree(tmp); 05065 } 05066 } 05067 #endif 05068 05069 #if defined(CONFIG_RSBAC_LIST_TRANS) || defined(CONFIG_RSBAC_LIST_REPL) 05070 kfree(list_info_p); 05071 #endif 05072 05073 return 0; 05074 }
int rsbac_list_lol_check | ( | rsbac_list_handle_t | handle, | |
int | correct | |||
) |
Definition at line 5545 of file gen_lists.c.
References rsbac_list_lol_item_t::count, rsbac_list_lol_info_t::data_size, rsbac_list_lol_reg_item_t::def_data, rsbac_list_lol_reg_item_t::def_subdata, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::device, do_remove_lol_item(), do_remove_lol_subitem(), rsbac_list_lol_reg_item_t::flags, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_hashed_t::head, rsbac_list_lol_item_t::head, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, rsbac_list_lol_item_t::max_age, rsbac_list_item_t::max_age, rsbac_list_lol_reg_item_t::name, rsbac_list_lol_item_t::next, rsbac_list_item_t::next, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, RSBAC_ENOTINITIALIZED, RSBAC_LIST_DEF_DATA, rsbac_pr_debug, rsbac_printk(), and rsbac_list_lol_reg_item_t::self.
05546 { 05547 struct rsbac_list_lol_reg_item_t *lol_list; 05548 struct rsbac_list_lol_item_t *lol_item_p; 05549 struct rsbac_list_lol_item_t *next_lol_item_p; 05550 struct rsbac_list_item_t *lol_subitem_p; 05551 struct rsbac_list_item_t *next_lol_subitem_p; 05552 u_long lock_flags; 05553 u_long rlock_flags; 05554 u_long tmp_count; 05555 u_long tmp_subcount; 05556 int i; 05557 05558 if (!handle) 05559 return -RSBAC_EINVALIDLIST; 05560 if (!list_initialized) 05561 return -RSBAC_ENOTINITIALIZED; 05562 05563 lol_list = (struct rsbac_list_lol_reg_item_t *) handle; 05564 if (!lol_list || (lol_list->self != lol_list)) 05565 return -RSBAC_EINVALIDLIST; 05566 05567 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 05568 rsbac_pr_debug(lists, "checking list %s.\n", lol_list->name); 05569 rsbac_write_lock(&lol_list->lock, &lock_flags); 05570 for (i=0; i<lol_list->nr_hashes; i++) { 05571 tmp_count = 0; 05572 lol_item_p = lol_list->hashed[i].head; 05573 while (lol_item_p) { 05574 if ((lol_item_p->max_age 05575 && (lol_item_p->max_age <= RSBAC_CURRENT_TIME) 05576 ) 05577 || (lol_list->def_data 05578 && !lol_item_p->count 05579 && !memcmp(((char *) lol_item_p) + 05580 sizeof(*lol_item_p) + 05581 lol_list->info.desc_size, 05582 lol_list->def_data, 05583 lol_list->info.data_size) 05584 ) 05585 || (!lol_list->info.data_size 05586 && (lol_list->flags & RSBAC_LIST_DEF_DATA) 05587 && !lol_item_p->count) 05588 ) { 05589 next_lol_item_p = lol_item_p->next; 05590 do_remove_lol_item(lol_list, lol_item_p, i); 05591 lol_item_p = next_lol_item_p; 05592 } else { 05593 tmp_count++; 05594 tmp_subcount = 0; 05595 lol_subitem_p = lol_item_p->head; 05596 while (lol_subitem_p) { 05597 if ((lol_subitem_p->max_age 05598 && (lol_subitem_p->max_age <= 05599 RSBAC_CURRENT_TIME) 05600 ) 05601 || (lol_list->def_subdata 05602 && !memcmp(((char *) lol_subitem_p) 05603 + 05604 sizeof(*lol_subitem_p) + 05605 lol_list->info. 05606 subdesc_size, 05607 lol_list->def_subdata, 05608 lol_list->info. 05609 subdata_size) 05610 ) 05611 ) { 05612 next_lol_subitem_p = 05613 lol_subitem_p->next; 05614 do_remove_lol_subitem(lol_item_p, 05615 lol_subitem_p); 05616 lol_subitem_p = next_lol_subitem_p; 05617 } else { 05618 tmp_subcount++; 05619 lol_subitem_p = 05620 lol_subitem_p->next; 05621 } 05622 } 05623 if (tmp_subcount != lol_item_p->count) { 05624 if (correct) { 05625 rsbac_printk(KERN_WARNING "rsbac_list_lol_check(): correcting count mismatch for list of lists %s hash %u sublist on %02u:%02u - was %lu, counted %lu!\n", 05626 lol_list->name, i, 05627 RSBAC_MAJOR(lol_list-> 05628 device), 05629 RSBAC_MINOR(lol_list-> 05630 device), 05631 lol_item_p->count, 05632 tmp_subcount); 05633 lol_item_p->count = tmp_subcount; 05634 } else { 05635 rsbac_printk(KERN_WARNING "rsbac_list_lol_check(): count mismatch for list of lists %s hash %u sublist on %02u:%02u - is %lu, counted %lu!\n", 05636 lol_list->name, i, 05637 RSBAC_MAJOR(lol_list-> 05638 device), 05639 RSBAC_MINOR(lol_list-> 05640 device), 05641 lol_item_p->count, 05642 tmp_subcount); 05643 } 05644 } 05645 lol_item_p = lol_item_p->next; 05646 } 05647 } 05648 if (tmp_count != lol_list->hashed[i].count) { 05649 if (correct) { 05650 rsbac_printk(KERN_WARNING "rsbac_list_lol_check(): correcting count mismatch for list of lists %s hash %u on %02u:%02u - was %u, counted %lu!\n", 05651 lol_list->name, i, 05652 RSBAC_MAJOR(lol_list->device), 05653 RSBAC_MINOR(lol_list->device), 05654 lol_list->hashed[i].count, tmp_count); 05655 lol_list->hashed[i].count = tmp_count; 05656 } else { 05657 rsbac_printk(KERN_WARNING "rsbac_list_lol_check(): count mismatch for list of lists %s hash %u on %02u:%02u - is %u, counted %lu!\n", 05658 lol_list->name, i, 05659 RSBAC_MAJOR(lol_list->device), 05660 RSBAC_MINOR(lol_list->device), 05661 lol_list->hashed[i].count, tmp_count); 05662 } 05663 } 05664 } 05665 rsbac_write_unlock(&lol_list->lock, &lock_flags); 05666 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 05667 return 0; 05668 }
long rsbac_list_lol_copy | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | from_handle, | |||
rsbac_list_handle_t | to_handle | |||
) |
Definition at line 10285 of file gen_lists.c.
References rsbac_list_lol_info_t::data_size, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_reg_item_t::info, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, rsbac_list_lol_reg_item_t::name, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EBUSY, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, rsbac_pr_debug, rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, rsbac_list_lol_info_t::subdata_size, and rsbac_list_lol_info_t::subdesc_size.
10288 { 10289 struct rsbac_list_lol_reg_item_t *from_list; 10290 struct rsbac_list_lol_reg_item_t *to_list; 10291 struct rsbac_list_lol_item_t *item_p; 10292 struct rsbac_list_lol_item_t *new_item_p; 10293 struct rsbac_list_item_t *subitem_p; 10294 struct rsbac_list_item_t *new_subitem_p; 10295 u_long rlock_flags, from_lock_flags, to_lock_flags; 10296 u_int subitem_size; 10297 int i; 10298 int err = 0; 10299 10300 if (!from_handle || !to_handle) 10301 return -RSBAC_EINVALIDLIST; 10302 10303 from_list = (struct rsbac_list_lol_reg_item_t *) from_handle; 10304 if (from_list->self != from_list) 10305 return -RSBAC_EINVALIDLIST; 10306 to_list = (struct rsbac_list_lol_reg_item_t *) to_handle; 10307 if (to_list->self != to_list) 10308 return -RSBAC_EINVALIDLIST; 10309 if((from_list->info.desc_size != to_list->info.desc_size) 10310 || (from_list->info.data_size != to_list->info.data_size) 10311 || (from_list->info.subdesc_size != to_list->info.subdesc_size) 10312 || (from_list->info.subdata_size != to_list->info.subdata_size)) 10313 return -RSBAC_EINVALIDVALUE; 10314 10315 #ifdef CONFIG_RSBAC_LIST_TRANS 10316 if (ta_number) { 10317 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 10318 return -RSBAC_EINVALIDTRANSACTION; 10319 } 10320 #endif 10321 10322 subitem_size = sizeof(*new_subitem_p) 10323 + from_list->info.subdesc_size + from_list->info.subdata_size; 10324 10325 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 10326 rsbac_pr_debug(lists, "list %s to list %s.\n", 10327 from_list->name, to_list->name); 10328 rsbac_read_lock(&from_list->lock, &from_lock_flags); 10329 rsbac_write_lock(&to_list->lock, &to_lock_flags); 10330 10331 #ifdef CONFIG_RSBAC_LIST_TRANS 10332 /* Check for other transactions at the target list */ 10333 if(ta_number) 10334 for (i=0; i<to_list->nr_hashes; i++) 10335 if(to_list->hashed[i].ta_copied != ta_number) { 10336 err = -RSBAC_EBUSY; 10337 goto out_unlock; 10338 } 10339 #endif 10340 for (i=0; i<to_list->nr_hashes; i++) { 10341 #ifdef CONFIG_RSBAC_LIST_TRANS 10342 if(ta_number && (to_list->hashed[i].ta_copied == ta_number)) 10343 ta_remove_all_lol_items(to_list, i); 10344 else 10345 #endif 10346 remove_all_lol_items(to_list, i); 10347 } 10348 for (i=0; i<from_list->nr_hashes; i++) { 10349 #ifdef CONFIG_RSBAC_LIST_TRANS 10350 if (ta_number) { 10351 if(from_list->hashed[i].ta_copied == ta_number) 10352 item_p = from_list->hashed[i].ta_head; 10353 else 10354 item_p = from_list->hashed[i].head; 10355 while(item_p) { 10356 new_item_p = ta_add_lol_item(ta_number, 10357 to_list, 10358 item_p->max_age, 10359 &item_p[1], 10360 &item_p[1] + from_list->info.desc_size); 10361 if(!new_item_p) { 10362 err = -RSBAC_EWRITEFAILED; 10363 goto out_unlock; 10364 } 10365 subitem_p = item_p->head; 10366 while (subitem_p) { 10367 if (!(new_subitem_p = rsbac_kmalloc(subitem_size))) { 10368 err = -RSBAC_ENOMEM; 10369 goto out_unlock; 10370 } 10371 memcpy(new_subitem_p, subitem_p, subitem_size); 10372 new_subitem_p->prev = NULL; 10373 new_subitem_p->next = NULL; 10374 if (new_item_p->tail) { 10375 new_subitem_p->prev = new_item_p->tail; 10376 new_item_p->tail->next = new_subitem_p; 10377 new_item_p->tail = new_subitem_p; 10378 new_item_p->count++; 10379 } else { 10380 new_item_p->head = new_subitem_p; 10381 new_item_p->tail = new_subitem_p; 10382 new_item_p->count = 1; 10383 } 10384 subitem_p = subitem_p->next; 10385 } 10386 item_p = item_p->next; 10387 } 10388 } 10389 else 10390 #endif 10391 { 10392 item_p = from_list->hashed[i].head; 10393 while(item_p) { 10394 new_item_p = add_lol_item(to_list, 10395 item_p->max_age, 10396 &item_p[1], 10397 &item_p[1] + from_list->info.desc_size); 10398 if(!new_item_p) { 10399 err = -RSBAC_EWRITEFAILED; 10400 goto out_unlock; 10401 } 10402 subitem_p = item_p->head; 10403 while (subitem_p) { 10404 if (!(new_subitem_p = rsbac_kmalloc(subitem_size))) { 10405 err = -RSBAC_ENOMEM; 10406 goto out_unlock; 10407 } 10408 memcpy(new_subitem_p, subitem_p, subitem_size); 10409 new_subitem_p->prev = NULL; 10410 new_subitem_p->next = NULL; 10411 if (new_item_p->tail) { 10412 new_subitem_p->prev = new_item_p->tail; 10413 new_item_p->tail->next = new_subitem_p; 10414 new_item_p->tail = new_subitem_p; 10415 new_item_p->count++; 10416 } else { 10417 new_item_p->head = new_subitem_p; 10418 new_item_p->tail = new_subitem_p; 10419 new_item_p->count = 1; 10420 } 10421 subitem_p = subitem_p->next; 10422 } 10423 item_p = item_p->next; 10424 } 10425 } 10426 } 10427 10428 out_unlock: 10429 rsbac_write_unlock(&to_list->lock, &to_lock_flags); 10430 rsbac_read_unlock(&from_list->lock, &from_lock_flags); 10431 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 10432 return err; 10433 }
int rsbac_list_lol_destroy | ( | rsbac_list_handle_t * | handle_p, | |
rsbac_list_key_t | key | |||
) |
Definition at line 6159 of file gen_lists.c.
References rsbac_list_lol_reg_item_t::flags, rsbac_list_lol_reg_item_t::info, rsbac_list_lol_info_t::key, list_initialized, rsbac_list_lol_reg_head_t::lock, lol_reg_head, lookup_lol_reg(), rsbac_list_lol_reg_item_t::name, NULL, proc_rsbac_backup_p, remove_lol_reg(), RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_ENOTINITIALIZED, RSBAC_LIST_BACKUP, rsbac_pr_debug, and rsbac_printk().
06161 { 06162 struct rsbac_list_lol_reg_item_t *reg_item_p; 06163 u_long lock_flags; 06164 int err = 0; 06165 06166 if (!handle_p) 06167 return -RSBAC_EINVALIDPOINTER; 06168 if (!*handle_p) 06169 return -RSBAC_EINVALIDLIST; 06170 if (!list_initialized) 06171 return -RSBAC_ENOTINITIALIZED; 06172 06173 rsbac_write_lock(&lol_reg_head.lock, &lock_flags); 06174 reg_item_p = 06175 lookup_lol_reg((struct rsbac_list_lol_reg_item_t *) *handle_p); 06176 if (!reg_item_p) { 06177 rsbac_write_unlock(&lol_reg_head.lock, &lock_flags); 06178 rsbac_printk(KERN_WARNING "rsbac_list_lol_destroy: destroying list failed due to invalid handle!\n"); 06179 return -RSBAC_EINVALIDLIST; 06180 } 06181 if (reg_item_p->info.key != key) { 06182 rsbac_write_unlock(&lol_reg_head.lock, &lock_flags); 06183 rsbac_printk(KERN_WARNING "rsbac_list_lol_destroy: destroying list %s denied due to invalid key %u!\n", 06184 reg_item_p->name, key); 06185 return -EPERM; 06186 } 06187 rsbac_pr_debug(lists, "destroying list %s.\n", 06188 reg_item_p->name); 06189 #if defined(CONFIG_RSBAC_PROC) 06190 /* delete proc entry, if it exists */ 06191 if ((reg_item_p->flags & RSBAC_LIST_BACKUP) 06192 && reg_item_p->proc_entry_p) { 06193 remove_proc_entry(reg_item_p->name, proc_rsbac_backup_p); 06194 reg_item_p->proc_entry_p = NULL; 06195 } 06196 #endif 06197 #if 0 06198 if (reg_item_p->flags & RSBAC_LIST_PERSIST) 06199 err = unlink_lol_list(reg_item_p); 06200 #endif 06201 06202 remove_lol_reg(reg_item_p); 06203 *handle_p = NULL; 06204 rsbac_write_unlock(&lol_reg_head.lock, &lock_flags); 06205 return err; 06206 }
int rsbac_list_lol_detach | ( | rsbac_list_handle_t * | handle_p, | |
rsbac_list_key_t | key | |||
) |
Definition at line 6287 of file gen_lists.c.
References rsbac_list_lol_write_head_t::count, rsbac_list_lol_reg_item_t::dirty, FALSE, fill_lol_buffer(), rsbac_list_lol_reg_item_t::flags, rsbac_list_lol_write_head_t::head, rsbac_list_lol_reg_item_t::info, rsbac_list_lol_info_t::key, list_initialized, rsbac_list_lol_reg_head_t::lock, lol_reg_head, lookup_lol_reg(), rsbac_list_lol_reg_item_t::name, rsbac_list_lol_reg_item_t::no_write, NULL, proc_rsbac_backup_p, remove_lol_reg(), RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_ENOTINITIALIZED, RSBAC_ENOTWRITABLE, RSBAC_LIST_BACKUP, rsbac_list_write_lol_buffers(), rsbac_printk(), rsbac_list_lol_write_head_t::tail, and TRUE.
Referenced by acl_detach_fd_lists(), auth_detach_fd_lists(), and mac_detach_fd_lists().
06289 { 06290 struct rsbac_list_lol_reg_item_t *reg_item_p; 06291 u_long lock_flags; 06292 int err = 0; 06293 06294 if (!handle_p) 06295 return -RSBAC_EINVALIDPOINTER; 06296 if (!*handle_p) 06297 return -RSBAC_EINVALIDLIST; 06298 if (!list_initialized) 06299 return -RSBAC_ENOTINITIALIZED; 06300 06301 rsbac_read_lock(&lol_reg_head.lock, &lock_flags); 06302 reg_item_p = 06303 lookup_lol_reg((struct rsbac_list_lol_reg_item_t *) *handle_p); 06304 if (!reg_item_p) { 06305 rsbac_read_unlock(&lol_reg_head.lock, &lock_flags); 06306 rsbac_printk(KERN_WARNING "rsbac_list_lol_detach: detaching list failed due to invalid handle!\n"); 06307 return -RSBAC_EINVALIDLIST; 06308 } 06309 if (reg_item_p->info.key != key) { 06310 rsbac_read_unlock(&lol_reg_head.lock, &lock_flags); 06311 rsbac_printk(KERN_WARNING "rsbac_list_lol_detach: detaching list %s denied due to invalid key %u!\n", 06312 reg_item_p->name, key); 06313 return -EPERM; 06314 } 06315 #if defined(CONFIG_RSBAC_PROC) 06316 /* delete proc entry, if it exists */ 06317 if ((reg_item_p->flags & RSBAC_LIST_BACKUP) 06318 && reg_item_p->proc_entry_p) { 06319 remove_proc_entry(reg_item_p->name, proc_rsbac_backup_p); 06320 reg_item_p->proc_entry_p = NULL; 06321 } 06322 #endif 06323 #ifndef CONFIG_RSBAC_NO_WRITE 06324 /* final write, if dirty etc. */ 06325 if ((reg_item_p->flags & RSBAC_LIST_PERSIST) 06326 && reg_item_p->dirty && !reg_item_p->no_write) { 06327 struct rsbac_list_lol_write_head_t write_head; 06328 struct rsbac_list_lol_write_item_t *write_item_p; 06329 06330 reg_item_p->dirty = FALSE; 06331 err = fill_lol_buffer(reg_item_p, &write_item_p); 06332 if (!err) { 06333 write_head.head = write_item_p; 06334 write_head.tail = write_item_p; 06335 write_head.count = 1; 06336 rsbac_read_unlock(&lol_reg_head.lock, &lock_flags); 06337 rsbac_list_write_lol_buffers(write_head, TRUE); 06338 } else { 06339 rsbac_read_unlock(&lol_reg_head.lock, &lock_flags); 06340 if (err != -RSBAC_ENOTWRITABLE) { 06341 rsbac_printk(KERN_WARNING "rsbac_list_lol_detach(): fill_buffer() for list %s returned error %i\n", 06342 reg_item_p->name, err); 06343 } 06344 } 06345 } else 06346 rsbac_read_unlock(&lol_reg_head.lock, &lock_flags); 06347 #else 06348 rsbac_read_unlock(&lol_reg_head.lock, &lock_flags); 06349 #endif 06350 /* disable handle */ 06351 *handle_p = NULL; 06352 /* too bad that the list might have been changed again - we do not care anymore */ 06353 rsbac_write_lock(&lol_reg_head.lock, &lock_flags); 06354 remove_lol_reg(reg_item_p); 06355 rsbac_write_unlock(&lol_reg_head.lock, &lock_flags); 06356 return err; 06357 }
int rsbac_list_lol_get_item_size | ( | rsbac_list_handle_t | handle | ) |
Definition at line 9773 of file gen_lists.c.
References rsbac_list_lol_info_t::data_size, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::info, list_initialized, RSBAC_EINVALIDLIST, RSBAC_ENOTINITIALIZED, and rsbac_list_lol_reg_item_t::self.
09774 { 09775 struct rsbac_list_lol_reg_item_t *list; 09776 09777 if (!handle) 09778 return -RSBAC_EINVALIDLIST; 09779 if (!list_initialized) 09780 return -RSBAC_ENOTINITIALIZED; 09781 09782 list = (struct rsbac_list_lol_reg_item_t *) handle; 09783 if (list->self != list) 09784 return -RSBAC_EINVALIDLIST; 09785 return list->info.desc_size + list->info.data_size; 09786 }
long rsbac_list_lol_get_nr_hashes | ( | rsbac_list_handle_t | handle | ) |
Definition at line 10635 of file gen_lists.c.
References list_initialized, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, RSBAC_ENOTINITIALIZED, and rsbac_list_lol_reg_item_t::self.
10636 { 10637 struct rsbac_list_lol_reg_item_t *list; 10638 10639 if (!handle) 10640 return -RSBAC_EINVALIDLIST; 10641 if (!list_initialized) 10642 return -RSBAC_ENOTINITIALIZED; 10643 10644 list = (struct rsbac_list_lol_reg_item_t *) handle; 10645 if (list->self != list) 10646 return -RSBAC_EINVALIDLIST; 10647 10648 return list->nr_hashes; 10649 }
int rsbac_list_lol_get_subitem_size | ( | rsbac_list_handle_t | handle | ) |
Definition at line 9755 of file gen_lists.c.
References rsbac_list_lol_reg_item_t::info, list_initialized, RSBAC_EINVALIDLIST, RSBAC_ENOTINITIALIZED, rsbac_list_lol_reg_item_t::self, rsbac_list_lol_info_t::subdata_size, and rsbac_list_lol_info_t::subdesc_size.
Referenced by rsbac_rc_copy_role().
09756 { 09757 struct rsbac_list_lol_reg_item_t *list; 09758 09759 if (!handle) 09760 return -RSBAC_EINVALIDLIST; 09761 if (!list_initialized) 09762 return -RSBAC_ENOTINITIALIZED; 09763 09764 list = (struct rsbac_list_lol_reg_item_t *) handle; 09765 if (list->self != list) 09766 return -RSBAC_EINVALIDLIST; 09767 return list->info.subdesc_size + list->info.subdata_size; 09768 }
int rsbac_list_lol_max_items | ( | rsbac_list_handle_t | handle, | |
rsbac_list_key_t | key, | |||
u_int | max_items, | |||
u_int | max_subitems | |||
) |
Definition at line 6467 of file gen_lists.c.
References rsbac_list_lol_reg_item_t::info, rsbac_list_lol_info_t::key, list_initialized, rsbac_list_lol_reg_head_t::lock, lol_reg_head, lookup_lol_reg(), rsbac_list_lol_reg_item_t::max_items_per_hash, rsbac_list_lol_reg_item_t::max_subitems, rsbac_list_lol_reg_item_t::name, RSBAC_EINVALIDLIST, RSBAC_ENOTINITIALIZED, RSBAC_LIST_MAX_NR_ITEMS_LIMIT, rsbac_min, and rsbac_printk().
06469 { 06470 struct rsbac_list_lol_reg_item_t *reg_item_p; 06471 u_long lock_flags; 06472 06473 if (!handle) 06474 return -RSBAC_EINVALIDLIST; 06475 if (!list_initialized) 06476 return -RSBAC_ENOTINITIALIZED; 06477 06478 rsbac_read_lock(&lol_reg_head.lock, &lock_flags); 06479 reg_item_p = lookup_lol_reg((struct rsbac_list_lol_reg_item_t *) handle); 06480 if (!reg_item_p) { 06481 rsbac_read_unlock(&lol_reg_head.lock, &lock_flags); 06482 rsbac_printk(KERN_WARNING "rsbac_list_lol_max_items: setting max_items_per_hash for list denied due to invalid handle!\n"); 06483 return -RSBAC_EINVALIDLIST; 06484 } 06485 if (reg_item_p->info.key != key) { 06486 rsbac_read_unlock(&lol_reg_head.lock, &lock_flags); 06487 rsbac_printk(KERN_WARNING "rsbac_list_lol_max_items: setting max_items_per_hash for list %s denied due to invalid key %u!\n", 06488 reg_item_p->name, key); 06489 return -EPERM; 06490 } 06491 reg_item_p->max_items_per_hash = rsbac_min(max_items, RSBAC_LIST_MAX_NR_ITEMS_LIMIT); 06492 reg_item_p->max_subitems = rsbac_min(max_subitems, RSBAC_LIST_MAX_NR_ITEMS_LIMIT); 06493 rsbac_read_unlock(&lol_reg_head.lock, &lock_flags); 06494 return 0; 06495 }
int rsbac_list_lol_no_write | ( | rsbac_list_handle_t | handle, | |
rsbac_list_key_t | key, | |||
rsbac_boolean_t | no_write | |||
) |
Definition at line 6398 of file gen_lists.c.
References FALSE, rsbac_list_lol_reg_item_t::info, rsbac_list_lol_info_t::key, list_initialized, rsbac_list_lol_reg_head_t::lock, lol_reg_head, lookup_lol_reg(), rsbac_list_lol_reg_item_t::name, rsbac_list_lol_reg_item_t::no_write, RSBAC_EINVALIDLIST, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, rsbac_printk(), and TRUE.
06400 { 06401 struct rsbac_list_lol_reg_item_t *reg_item_p; 06402 u_long lock_flags; 06403 06404 if (!handle) 06405 return -RSBAC_EINVALIDLIST; 06406 if ((no_write != FALSE) && (no_write != TRUE)) 06407 return -RSBAC_EINVALIDVALUE; 06408 if (!list_initialized) 06409 return -RSBAC_ENOTINITIALIZED; 06410 06411 rsbac_read_lock(&lol_reg_head.lock, &lock_flags); 06412 reg_item_p = 06413 lookup_lol_reg((struct rsbac_list_lol_reg_item_t *) handle); 06414 if (!reg_item_p) { 06415 rsbac_read_unlock(&lol_reg_head.lock, &lock_flags); 06416 rsbac_printk(KERN_WARNING "rsbac_list_lol_no_write: setting no_write for list denied due to invalid handle!\n"); 06417 return -RSBAC_EINVALIDLIST; 06418 } 06419 if (reg_item_p->info.key != key) { 06420 rsbac_read_unlock(&lol_reg_head.lock, &lock_flags); 06421 rsbac_printk(KERN_WARNING "rsbac_list_lol_no_write: setting no_write for list %s denied due to invalid key %u!\n", 06422 reg_item_p->name, key); 06423 return -EPERM; 06424 } 06425 reg_item_p->no_write = no_write; 06426 rsbac_read_unlock(&lol_reg_head.lock, &lock_flags); 06427 return 0; 06428 }
int rsbac_list_lol_register | ( | rsbac_version_t | ds_version, | |
rsbac_list_handle_t * | handle_p, | |||
struct rsbac_list_lol_info_t * | info_p, | |||
u_int | flags, | |||
rsbac_list_compare_function_t * | compare, | |||
rsbac_list_compare_function_t * | subcompare, | |||
rsbac_list_get_conv_t * | get_conv, | |||
rsbac_list_get_conv_t * | get_subconv, | |||
void * | def_data, | |||
void * | def_subdata, | |||
char * | name, | |||
kdev_t | device | |||
) |
Definition at line 6083 of file gen_lists.c.
References NULL, and rsbac_list_lol_register_hashed().
Referenced by rsbac_init_acl(), rsbac_init_mac(), and rsbac_init_pm().
06092 { 06093 return rsbac_list_lol_register_hashed (ds_version, handle_p, info_p, 06094 flags, compare, subcompare, get_conv, 06095 get_subconv, def_data, def_subdata, 06096 name, device, 06097 1, NULL, NULL); 06098 }
int rsbac_list_lol_register_hashed | ( | rsbac_version_t | ds_version, | |
rsbac_list_handle_t * | handle_p, | |||
struct rsbac_list_lol_info_t * | info_p, | |||
u_int | flags, | |||
rsbac_list_compare_function_t * | compare, | |||
rsbac_list_compare_function_t * | subcompare, | |||
rsbac_list_get_conv_t * | get_conv, | |||
rsbac_list_get_conv_t * | get_subconv, | |||
void * | def_data, | |||
void * | def_subdata, | |||
char * | name, | |||
kdev_t | device, | |||
u_int | nr_hashes, | |||
rsbac_list_hash_function_t | hash_function, | |||
char * | old_base_name | |||
) |
Definition at line 5932 of file gen_lists.c.
References add_lol_reg(), clear_lol_reg(), create_lol_reg(), rsbac_list_lol_info_t::data_size, rsbac_list_lol_info_t::desc_size, get_error_name(), rsbac_list_lol_info_t::key, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_reg_head_t::lock, lol_reg_head, lookup_lol_reg_name(), lookup_reg_name(), rsbac_list_lol_info_t::max_age, rsbac_list_lol_reg_item_t::name, NULL, proc_rsbac_backup_p, read_lol_list(), reg_head, RSBAC_ECOULDNOTADDITEM, RSBAC_EEXISTS, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDVALUE, RSBAC_EINVALIDVERSION, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, RSBAC_LIST_AUTO_HASH_RESIZE, RSBAC_LIST_BACKUP, rsbac_list_lol_max_hashes, RSBAC_LIST_MAX_AGE_LIMIT, RSBAC_LIST_MAX_ITEM_SIZE, RSBAC_LIST_VERSION, RSBAC_MAXNAMELEN, rsbac_pr_debug, rsbac_printk(), rsbac_root_dev, rsbac_list_lol_info_t::subdata_size, rsbac_list_lol_info_t::subdesc_size, and rsbac_list_lol_info_t::version.
Referenced by acl_register_fd_lists(), auth_register_fd_lists(), mac_register_fd_lists(), rsbac_init_acl(), rsbac_init_auth(), rsbac_init_rc(), rsbac_init_um(), and rsbac_list_lol_register().
05945 { 05946 struct rsbac_list_lol_reg_item_t *reg_item_p; 05947 struct rsbac_list_lol_reg_item_t *new_reg_item_p; 05948 u_long lock_flags; 05949 int err = 0; 05950 05951 if (ds_version != RSBAC_LIST_VERSION) 05952 return -RSBAC_EINVALIDVERSION; 05953 if (!handle_p) 05954 return -RSBAC_EINVALIDPOINTER; 05955 *handle_p = NULL; 05956 if (!list_initialized) 05957 return -RSBAC_ENOTINITIALIZED; 05958 if (!info_p->key || !info_p->version || !info_p->desc_size) 05959 return -RSBAC_EINVALIDVALUE; 05960 if (info_p->max_age > RSBAC_LIST_MAX_AGE_LIMIT) 05961 return -RSBAC_EINVALIDVALUE; 05962 if (info_p->desc_size + info_p->data_size > 05963 RSBAC_LIST_MAX_ITEM_SIZE) 05964 return -RSBAC_EINVALIDVALUE; 05965 if (info_p->subdesc_size + info_p->subdata_size > 05966 RSBAC_LIST_MAX_ITEM_SIZE) 05967 return -RSBAC_EINVALIDVALUE; 05968 if (nr_hashes > rsbac_list_lol_max_hashes) 05969 nr_hashes = rsbac_list_lol_max_hashes; 05970 else if (nr_hashes > 2) { 05971 u_int i = 1; 05972 05973 while ((i << 1) <= nr_hashes) 05974 i = i << 1; 05975 nr_hashes = i; 05976 } 05977 if (!hash_function) { 05978 nr_hashes = 1; 05979 flags &= ~RSBAC_LIST_AUTO_HASH_RESIZE; 05980 } else 05981 if (!nr_hashes) 05982 nr_hashes = 1; 05983 if (name) { 05984 struct rsbac_list_reg_item_t *std_reg_item_p; 05985 05986 rsbac_read_lock(&lol_reg_head.lock, &lock_flags); 05987 reg_item_p = lookup_lol_reg_name(name, device); 05988 rsbac_read_unlock(&lol_reg_head.lock, &lock_flags); 05989 if (reg_item_p) { 05990 rsbac_pr_debug(lists, "list name %s already exists on device %02u:%02u!\n", 05991 name, RSBAC_MAJOR(device), 05992 RSBAC_MINOR(device)); 05993 return -RSBAC_EEXISTS; 05994 } 05995 rsbac_read_lock(®_head.lock, &lock_flags); 05996 std_reg_item_p = lookup_reg_name(name, device); 05997 rsbac_read_unlock(®_head.lock, &lock_flags); 05998 if (std_reg_item_p) { 05999 rsbac_pr_debug(lists, "list name %s already exists on device %02u:%02u!\n", 06000 name, RSBAC_MAJOR(device), 06001 RSBAC_MINOR(device)); 06002 return -RSBAC_EEXISTS; 06003 } 06004 } else if (flags & RSBAC_LIST_PERSIST) { 06005 rsbac_printk(KERN_WARNING "rsbac_list_lol_register: trial to register persistent list of lists without name.\n"); 06006 return -RSBAC_EINVALIDVALUE; 06007 } 06008 06009 if (flags & RSBAC_LIST_PERSIST) { 06010 if (RSBAC_IS_AUTO_DEV(device)) 06011 device = rsbac_root_dev; 06012 if (!RSBAC_MAJOR(device)) 06013 flags &= ~RSBAC_LIST_PERSIST; 06014 } 06015 rsbac_pr_debug(lists, "registering list of lists %s.\n", 06016 name); 06017 new_reg_item_p = create_lol_reg(info_p, flags, compare, subcompare, 06018 get_conv, get_subconv, 06019 def_data, def_subdata, 06020 name, device, 06021 nr_hashes, hash_function, 06022 old_base_name); 06023 if (!new_reg_item_p) { 06024 return -RSBAC_ECOULDNOTADDITEM; 06025 } 06026 /* Restore from disk */ 06027 if (flags & RSBAC_LIST_PERSIST) { 06028 rsbac_pr_debug(lists, "restoring list %s from device %02u:%02u.\n", 06029 name, RSBAC_MAJOR(device), 06030 RSBAC_MINOR(device)); 06031 err = read_lol_list(new_reg_item_p); 06032 /* not found is no error */ 06033 if (err == -RSBAC_ENOTFOUND) 06034 err = 0; 06035 else if (err) { 06036 char tmp[RSBAC_MAXNAMELEN]; 06037 rsbac_pr_debug(lists, "restoring list %s from device %02u:%02u failed with error %s, unregistering list.\n", 06038 name, RSBAC_MAJOR(device), 06039 RSBAC_MINOR(device), 06040 get_error_name(tmp, err)); 06041 clear_lol_reg(new_reg_item_p); 06042 return err; 06043 } else 06044 rsbac_pr_debug(lists, "restoring list %s from device %02u:%02u was successful.\n", 06045 name, RSBAC_MAJOR(device), 06046 RSBAC_MINOR(device)); 06047 } 06048 06049 rsbac_write_lock(&lol_reg_head.lock, &lock_flags); 06050 reg_item_p = add_lol_reg(new_reg_item_p); 06051 rsbac_write_unlock(&lol_reg_head.lock, &lock_flags); 06052 if (!reg_item_p) { 06053 rsbac_printk(KERN_WARNING "rsbac_list_lol_register: inserting list %s failed!\n", 06054 name); 06055 /* cleanup */ 06056 clear_lol_reg(new_reg_item_p); 06057 return -RSBAC_ECOULDNOTADDITEM; 06058 } 06059 06060 /* finish */ 06061 #if defined(CONFIG_RSBAC_PROC) 06062 /* create proc entry, if requested */ 06063 if (flags & RSBAC_LIST_BACKUP) { 06064 reg_item_p->proc_entry_p = 06065 create_proc_entry(reg_item_p->name, S_IFREG | S_IRUGO, 06066 proc_rsbac_backup_p); 06067 if (reg_item_p->proc_entry_p) { 06068 reg_item_p->proc_entry_p->read_proc = 06069 lol_backup_proc_read; 06070 reg_item_p->proc_entry_p->data = reg_item_p; 06071 } 06072 } else { 06073 reg_item_p->proc_entry_p = NULL; 06074 } 06075 #endif 06076 *handle_p = reg_item_p; 06077 return err; 06078 }
int rsbac_list_max_items | ( | rsbac_list_handle_t | handle, | |
rsbac_list_key_t | key, | |||
u_int | max_items | |||
) |
Definition at line 6434 of file gen_lists.c.
References rsbac_list_reg_item_t::info, rsbac_list_info_t::key, list_initialized, rsbac_list_reg_head_t::lock, lookup_reg(), rsbac_list_reg_item_t::max_items_per_hash, rsbac_list_reg_item_t::name, reg_head, RSBAC_EINVALIDLIST, RSBAC_ENOTINITIALIZED, RSBAC_LIST_MAX_NR_ITEMS_LIMIT, rsbac_min, and rsbac_printk().
06436 { 06437 struct rsbac_list_reg_item_t *reg_item_p; 06438 u_long lock_flags; 06439 06440 if (!handle) 06441 return -RSBAC_EINVALIDLIST; 06442 if (!list_initialized) 06443 return -RSBAC_ENOTINITIALIZED; 06444 06445 rsbac_read_lock(®_head.lock, &lock_flags); 06446 reg_item_p = lookup_reg((struct rsbac_list_reg_item_t *) handle); 06447 if (!reg_item_p) { 06448 rsbac_read_unlock(®_head.lock, &lock_flags); 06449 rsbac_printk(KERN_WARNING "rsbac_list_max_items: setting max_items_per_hash for list denied due to invalid handle!\n"); 06450 return -RSBAC_EINVALIDLIST; 06451 } 06452 if (reg_item_p->info.key != key) { 06453 rsbac_read_unlock(®_head.lock, &lock_flags); 06454 rsbac_printk(KERN_WARNING "rsbac_list_max_items: setting max_items_per_hash for list %s denied due to invalid key %u!\n", 06455 reg_item_p->name, key); 06456 return -EPERM; 06457 } 06458 reg_item_p->max_items_per_hash = rsbac_min(max_items, RSBAC_LIST_MAX_NR_ITEMS_LIMIT); 06459 rsbac_read_unlock(®_head.lock, &lock_flags); 06460 return 0; 06461 }
int rsbac_list_mount | ( | kdev_t | kdev | ) |
int rsbac_list_no_write | ( | rsbac_list_handle_t | handle, | |
rsbac_list_key_t | key, | |||
rsbac_boolean_t | no_write | |||
) |
Definition at line 6364 of file gen_lists.c.
References FALSE, rsbac_list_reg_item_t::info, rsbac_list_info_t::key, list_initialized, rsbac_list_reg_head_t::lock, lookup_reg(), rsbac_list_reg_item_t::name, rsbac_list_reg_item_t::no_write, reg_head, RSBAC_EINVALIDLIST, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, rsbac_printk(), and TRUE.
06366 { 06367 struct rsbac_list_reg_item_t *reg_item_p; 06368 u_long lock_flags; 06369 06370 if (!handle) 06371 return -RSBAC_EINVALIDLIST; 06372 if ((no_write != FALSE) && (no_write != TRUE)) 06373 return -RSBAC_EINVALIDVALUE; 06374 if (!list_initialized) 06375 return -RSBAC_ENOTINITIALIZED; 06376 06377 rsbac_read_lock(®_head.lock, &lock_flags); 06378 reg_item_p = lookup_reg((struct rsbac_list_reg_item_t *) handle); 06379 if (!reg_item_p) { 06380 rsbac_read_unlock(®_head.lock, &lock_flags); 06381 rsbac_printk(KERN_WARNING "rsbac_list_no_write: setting no_write for list denied due to invalid handle!\n"); 06382 return -RSBAC_EINVALIDLIST; 06383 } 06384 if (reg_item_p->info.key != key) { 06385 rsbac_read_unlock(®_head.lock, &lock_flags); 06386 rsbac_printk(KERN_WARNING "rsbac_list_no_write: setting no_write for list %s denied due to invalid key %u!\n", 06387 reg_item_p->name, key); 06388 return -EPERM; 06389 } 06390 reg_item_p->no_write = no_write; 06391 rsbac_read_unlock(®_head.lock, &lock_flags); 06392 return 0; 06393 }
int rsbac_list_register | ( | rsbac_version_t | ds_version, | |
rsbac_list_handle_t * | handle_p, | |||
struct rsbac_list_info_t * | info_p, | |||
u_int | flags, | |||
rsbac_list_compare_function_t * | compare, | |||
rsbac_list_get_conv_t * | get_conv, | |||
void * | def_data, | |||
char * | name, | |||
kdev_t | device | |||
) |
Definition at line 5870 of file gen_lists.c.
References NULL, and rsbac_list_register_hashed().
Referenced by init_module(), register_user_lists1(), register_user_lists2(), rsbac_init_acl(), rsbac_init_debug(), rsbac_init_pm(), and rsbac_list_init().
05877 { 05878 return rsbac_list_register_hashed(ds_version, handle_p, info_p, flags, 05879 compare, get_conv, def_data, name, device, 05880 1, NULL, NULL); 05881 }
int rsbac_list_register_hashed | ( | rsbac_version_t | ds_version, | |
rsbac_list_handle_t * | handle_p, | |||
struct rsbac_list_info_t * | info_p, | |||
u_int | flags, | |||
rsbac_list_compare_function_t * | compare, | |||
rsbac_list_get_conv_t * | get_conv, | |||
void * | def_data, | |||
char * | name, | |||
kdev_t | device, | |||
u_int | nr_hashes, | |||
rsbac_list_hash_function_t | hash_function, | |||
char * | old_base_name | |||
) |
Definition at line 5722 of file gen_lists.c.
References add_reg(), clear_reg(), create_reg(), rsbac_list_info_t::data_size, rsbac_list_info_t::desc_size, get_error_name(), rsbac_list_info_t::key, list_initialized, rsbac_list_reg_head_t::lock, rsbac_list_lol_reg_head_t::lock, lol_reg_head, lookup_lol_reg_name(), lookup_reg_name(), rsbac_list_info_t::max_age, rsbac_list_reg_item_t::name, NULL, proc_rsbac_backup_p, read_list(), reg_head, RSBAC_ECOULDNOTADDITEM, RSBAC_EEXISTS, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDVALUE, RSBAC_EINVALIDVERSION, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, RSBAC_LIST_AUTO_HASH_RESIZE, RSBAC_LIST_BACKUP, RSBAC_LIST_MAX_AGE_LIMIT, rsbac_list_max_hashes, RSBAC_LIST_MAX_ITEM_SIZE, RSBAC_LIST_VERSION, RSBAC_MAXNAMELEN, rsbac_pr_debug, rsbac_printk(), rsbac_root_dev, and rsbac_list_info_t::version.
Referenced by register_dev_lists(), register_fd_lists(), register_ipc_lists(), register_process_lists(), register_user_lists1(), register_user_lists2(), rsbac_init_acl(), rsbac_init_rc(), rsbac_init_um(), and rsbac_list_register().
05732 { 05733 struct rsbac_list_reg_item_t *reg_item_p; 05734 struct rsbac_list_reg_item_t *new_reg_item_p; 05735 u_long lock_flags; 05736 int err = 0; 05737 05738 if (ds_version != RSBAC_LIST_VERSION) { 05739 if (name) { 05740 rsbac_printk(KERN_WARNING "rsbac_list_register: wrong ds_version %u for list %s, expected %u!\n", 05741 ds_version, name, RSBAC_LIST_VERSION); 05742 } 05743 return -RSBAC_EINVALIDVERSION; 05744 } 05745 if (!handle_p || !info_p) 05746 return -RSBAC_EINVALIDPOINTER; 05747 *handle_p = NULL; 05748 if (!list_initialized) 05749 return -RSBAC_ENOTINITIALIZED; 05750 if (!info_p->key || !info_p->version || !info_p->desc_size) 05751 return -RSBAC_EINVALIDVALUE; 05752 if (info_p->max_age > RSBAC_LIST_MAX_AGE_LIMIT) 05753 return -RSBAC_EINVALIDVALUE; 05754 if (info_p->desc_size + info_p->data_size > 05755 RSBAC_LIST_MAX_ITEM_SIZE) 05756 return -RSBAC_EINVALIDVALUE; 05757 if (nr_hashes > rsbac_list_max_hashes) 05758 nr_hashes = rsbac_list_max_hashes; 05759 else if (nr_hashes > 2) { 05760 u_int i = 1; 05761 05762 while ((i << 1) <= nr_hashes) 05763 i = i << 1; 05764 nr_hashes = i; 05765 } 05766 if (!hash_function) { 05767 nr_hashes = 1; 05768 flags &= ~RSBAC_LIST_AUTO_HASH_RESIZE; 05769 } else 05770 if (!nr_hashes) 05771 nr_hashes = 1; 05772 if (name) { 05773 struct rsbac_list_lol_reg_item_t *lol_reg_item_p; 05774 05775 rsbac_read_lock(®_head.lock, &lock_flags); 05776 reg_item_p = lookup_reg_name(name, device); 05777 rsbac_read_unlock(®_head.lock, &lock_flags); 05778 if (reg_item_p) { 05779 rsbac_pr_debug(lists, "list name %s already exists on device %02u:%02u!\n", 05780 name, RSBAC_MAJOR(device), 05781 RSBAC_MINOR(device)); 05782 return -RSBAC_EEXISTS; 05783 } 05784 rsbac_read_lock(&lol_reg_head.lock, &lock_flags); 05785 lol_reg_item_p = lookup_lol_reg_name(name, device); 05786 rsbac_read_unlock(&lol_reg_head.lock, &lock_flags); 05787 if (lol_reg_item_p) { 05788 rsbac_pr_debug(lists, "list name %s already exists on device %02u:%02u!\n", 05789 name, RSBAC_MAJOR(device), 05790 RSBAC_MINOR(device)); 05791 return -RSBAC_EEXISTS; 05792 } 05793 } else if (flags & RSBAC_LIST_PERSIST) { 05794 rsbac_printk(KERN_WARNING "rsbac_list_register: trial to register persistent list without name.\n"); 05795 return -RSBAC_EINVALIDVALUE; 05796 } 05797 05798 if (flags & RSBAC_LIST_PERSIST) { 05799 if (RSBAC_IS_AUTO_DEV(device)) 05800 device = rsbac_root_dev; 05801 if (!RSBAC_MAJOR(device)) 05802 flags &= ~RSBAC_LIST_PERSIST; 05803 } 05804 rsbac_pr_debug(lists, "registering list %s for device %02u:%02u.\n", 05805 name, RSBAC_MAJOR(device), RSBAC_MINOR(device)); 05806 new_reg_item_p = 05807 create_reg(info_p, flags, compare, get_conv, def_data, name, 05808 device, nr_hashes, hash_function, old_base_name); 05809 if (!new_reg_item_p) { 05810 return -RSBAC_ECOULDNOTADDITEM; 05811 } 05812 /* Restore from disk, but only for real device mounts */ 05813 if ((flags & RSBAC_LIST_PERSIST) 05814 && RSBAC_MAJOR(device) 05815 ) { 05816 rsbac_pr_debug(lists, "restoring list %s from device %02u:%02u.\n", 05817 name, RSBAC_MAJOR(device), RSBAC_MINOR(device)); 05818 err = read_list(new_reg_item_p); 05819 /* not found is no error */ 05820 if (err == -RSBAC_ENOTFOUND) 05821 err = 0; 05822 else if (err) { 05823 char tmp[RSBAC_MAXNAMELEN]; 05824 rsbac_pr_debug(lists, "restoring list %s from device %02u:%02u failed with error %s, unregistering list.\n", name, 05825 RSBAC_MAJOR(device), 05826 RSBAC_MINOR(device), 05827 get_error_name(tmp, err)); 05828 clear_reg(new_reg_item_p); 05829 return err; 05830 } else 05831 rsbac_pr_debug(lists, "restoring list %s from device %02u:%02u was successful.\n", 05832 name, RSBAC_MAJOR(device), 05833 RSBAC_MINOR(device)); 05834 } 05835 05836 rsbac_write_lock(®_head.lock, &lock_flags); 05837 reg_item_p = add_reg(new_reg_item_p); 05838 rsbac_write_unlock(®_head.lock, &lock_flags); 05839 if (!reg_item_p) { 05840 rsbac_printk(KERN_WARNING "rsbac_list_register: inserting list %s failed!\n", 05841 name); 05842 /* cleanup */ 05843 clear_reg(new_reg_item_p); 05844 return -RSBAC_ECOULDNOTADDITEM; 05845 } 05846 05847 /* finish */ 05848 #if defined(CONFIG_RSBAC_PROC) 05849 /* create proc entry, if requested */ 05850 if (flags & RSBAC_LIST_BACKUP) { 05851 reg_item_p->proc_entry_p = 05852 create_proc_entry(reg_item_p->name, S_IFREG | S_IRUGO, 05853 proc_rsbac_backup_p); 05854 if (reg_item_p->proc_entry_p) { 05855 reg_item_p->proc_entry_p->read_proc = 05856 backup_proc_read; 05857 reg_item_p->proc_entry_p->data = reg_item_p; 05858 } 05859 } else { 05860 reg_item_p->proc_entry_p = NULL; 05861 } 05862 #endif 05863 *handle_p = reg_item_p; 05864 return err; 05865 }
int rsbac_list_umount | ( | kdev_t | kdev | ) |
rsbac_version_t rsbac_list_version | ( | void | ) |
Definition at line 5676 of file gen_lists.c.
References RSBAC_LIST_VERSION.
05677 { 05678 return RSBAC_LIST_VERSION; 05679 }
static int rsbac_list_write_buffers | ( | struct rsbac_list_write_head_t | write_head, | |
rsbac_boolean_t | need_lock | |||
) | [static] |
Definition at line 3881 of file gen_lists.c.
References rsbac_list_write_item_t::buffer, rsbac_list_buffer_t::data, rsbac_list_write_item_t::device, rsbac_list_reg_item_t::dirty, free_buffers(), rsbac_list_write_head_t::head, rsbac_list_buffer_t::len, rsbac_list_write_item_t::list, rsbac_list_write_item_t::name, rsbac_list_write_item_t::next, rsbac_list_buffer_t::next, RSBAC_ENOMEM, RSBAC_ENOTWRITABLE, rsbac_kfree(), rsbac_kmalloc(), rsbac_pr_debug, rsbac_printk(), rsbac_write_close(), rsbac_write_open(), rsbac_list_reg_item_t::self, and TRUE.
Referenced by rsbac_list_detach().
03883 { 03884 struct file *file_p; 03885 int count = 0; 03886 mm_segment_t oldfs; 03887 u_int written; 03888 u_long all_written; 03889 u_long bytes; 03890 u_int bufcount; 03891 int tmperr = 0; 03892 struct rsbac_list_buffer_t * buffer; 03893 struct rsbac_list_write_item_t *write_item_p; 03894 struct rsbac_list_write_item_t *next_item_p; 03895 03896 write_item_p = write_head.head; 03897 file_p = rsbac_kmalloc(sizeof(*file_p)); 03898 if (!file_p) { 03899 count = -RSBAC_ENOMEM; 03900 goto out_free_all; 03901 } 03902 while (write_item_p) { 03903 rsbac_pr_debug(write, "write list %s on device %02u:%02u.\n", 03904 write_item_p->name, 03905 RSBAC_MAJOR(write_item_p->device), 03906 RSBAC_MINOR(write_item_p->device)); 03907 if (need_lock) 03908 lock_kernel(); 03909 /* open file */ 03910 if ((tmperr = rsbac_write_open(write_item_p->name, 03911 file_p, 03912 write_item_p->device))) { 03913 if (tmperr != -RSBAC_ENOTWRITABLE) { 03914 rsbac_printk(KERN_WARNING "rsbac_list_write_buffers(): opening file %s on device %02u:%02u failed with error %i!\n", 03915 write_item_p->name, 03916 RSBAC_MAJOR(write_item_p-> 03917 device), 03918 RSBAC_MINOR(write_item_p-> 03919 device), tmperr); 03920 } 03921 count = tmperr; 03922 if(need_lock) 03923 unlock_kernel(); 03924 goto out_free_all; 03925 } 03926 03927 /* OK, now we can start writing the buffer. */ 03928 /* Set current user space to kernel space, because write() reads */ 03929 /* from user space */ 03930 oldfs = get_fs(); 03931 set_fs(KERNEL_DS); 03932 03933 buffer = write_item_p->buffer; 03934 all_written = 0; 03935 bufcount = 0; 03936 while (buffer && (tmperr >= 0)) { 03937 rsbac_pr_debug(write, "Writing list %s, buffer %u with size %u\n", 03938 write_item_p->name, bufcount, buffer->len); 03939 bufcount++; 03940 written = 0; 03941 while ((written < buffer->len) && (tmperr >= 0)) { 03942 bytes = buffer->len - written; 03943 tmperr = file_p->f_op->write(file_p, 03944 buffer->data + written, 03945 bytes, 03946 &file_p->f_pos); 03947 if (tmperr > 0) { 03948 written += tmperr; 03949 } 03950 } 03951 all_written += written; 03952 buffer = buffer->next; 03953 } 03954 /* Set current user space back to user space, because write() reads */ 03955 /* from user space */ 03956 set_fs(oldfs); 03957 /* End of write access */ 03958 rsbac_write_close(file_p); 03959 if (need_lock) 03960 unlock_kernel(); 03961 if (tmperr < 0) { 03962 rsbac_printk(KERN_WARNING "rsbac_list_write_buffers(): write error %i on device %02u:%02u file %s!\n", 03963 tmperr, 03964 RSBAC_MAJOR(write_item_p->device), 03965 RSBAC_MINOR(write_item_p->device), 03966 write_item_p->name); 03967 count = tmperr; 03968 goto out_free_all; 03969 } else 03970 count++; 03971 03972 rsbac_pr_debug(write, "%lu bytes from %u buffers written.\n", 03973 all_written, bufcount); 03974 03975 free_buffers(write_item_p->buffer); 03976 next_item_p = write_item_p->next; 03977 rsbac_kfree(write_item_p); 03978 write_item_p = next_item_p; 03979 } 03980 /* Ready. */ 03981 rsbac_kfree(file_p); 03982 return count; 03983 03984 out_free_all: 03985 /* Mark unwritten lists dirty and free everything */ 03986 while(write_item_p) 03987 { 03988 if(write_item_p->list->self == write_item_p->list) 03989 write_item_p->list->dirty = TRUE; 03990 free_buffers(write_item_p->buffer); 03991 next_item_p = write_item_p->next; 03992 rsbac_kfree(write_item_p); 03993 write_item_p = next_item_p; 03994 } 03995 if(file_p) 03996 rsbac_kfree(file_p); 03997 return count; 03998 }
static int rsbac_list_write_lol_buffers | ( | struct rsbac_list_lol_write_head_t | write_head, | |
rsbac_boolean_t | need_lock | |||
) | [static] |
Definition at line 4126 of file gen_lists.c.
References rsbac_list_lol_write_item_t::buffer, rsbac_list_buffer_t::data, rsbac_list_lol_write_item_t::device, rsbac_list_lol_reg_item_t::dirty, free_buffers(), rsbac_list_lol_write_head_t::head, rsbac_list_buffer_t::len, rsbac_list_lol_write_item_t::list, rsbac_list_lol_write_item_t::name, rsbac_list_lol_write_item_t::next, rsbac_list_buffer_t::next, RSBAC_ENOMEM, RSBAC_ENOTWRITABLE, rsbac_kfree(), rsbac_kmalloc(), rsbac_pr_debug, rsbac_printk(), rsbac_write_close(), rsbac_write_open(), rsbac_list_lol_reg_item_t::self, and TRUE.
Referenced by rsbac_list_lol_detach().
04129 { 04130 struct file *file_p; 04131 int count = 0; 04132 mm_segment_t oldfs; 04133 u_long written; 04134 u_long all_written; 04135 u_long bytes; 04136 u_int bufcount; 04137 int tmperr = 0; 04138 struct rsbac_list_buffer_t * buffer; 04139 struct rsbac_list_lol_write_item_t *write_item_p; 04140 struct rsbac_list_lol_write_item_t *next_item_p; 04141 04142 write_item_p = write_head.head; 04143 file_p = rsbac_kmalloc(sizeof(*file_p)); 04144 if (!file_p) { 04145 count = -RSBAC_ENOMEM; 04146 goto out_free_all; 04147 } 04148 while (write_item_p) { 04149 rsbac_pr_debug(write, "write list of lists %s on device %02u:%02u.\n", 04150 write_item_p->name, 04151 RSBAC_MAJOR(write_item_p->device), 04152 RSBAC_MINOR(write_item_p->device)); 04153 if (need_lock) 04154 lock_kernel(); 04155 /* open file */ 04156 if ((tmperr = rsbac_write_open(write_item_p->name, 04157 file_p, 04158 write_item_p->device))) { 04159 if (tmperr != -RSBAC_ENOTWRITABLE) { 04160 rsbac_printk(KERN_WARNING "rsbac_list_write_lol_buffers(): opening file %s on device %02u:%02u failed with error %i!\n", 04161 write_item_p->name, 04162 RSBAC_MAJOR(write_item_p-> 04163 device), 04164 RSBAC_MINOR(write_item_p-> 04165 device), tmperr); 04166 } 04167 if (need_lock) 04168 unlock_kernel(); 04169 goto out_free_all; 04170 } 04171 04172 /* OK, now we can start writing the buffer. */ 04173 /* Set current user space to kernel space, because write() reads */ 04174 /* from user space */ 04175 oldfs = get_fs(); 04176 set_fs(KERNEL_DS); 04177 04178 buffer = write_item_p->buffer; 04179 all_written = 0; 04180 bufcount = 0; 04181 while (buffer && (tmperr >= 0)) { 04182 rsbac_pr_debug(write, "Writing list of lists %s, buffer %u with size %u\n", 04183 write_item_p->name, bufcount, buffer->len); 04184 bufcount++; 04185 written = 0; 04186 while ((written < buffer->len) && (tmperr >= 0)) { 04187 bytes = buffer->len - written; 04188 tmperr = file_p->f_op->write(file_p, 04189 buffer->data + written, 04190 bytes, 04191 &file_p->f_pos); 04192 if (tmperr > 0) { 04193 written += tmperr; 04194 } 04195 } 04196 all_written += written; 04197 buffer = buffer->next; 04198 } 04199 /* Set current user space back to user space, because write() reads */ 04200 /* from user space */ 04201 set_fs(oldfs); 04202 /* End of write access */ 04203 rsbac_write_close(file_p); 04204 04205 if (need_lock) 04206 unlock_kernel(); 04207 04208 if (tmperr < 0) { 04209 rsbac_printk(KERN_WARNING "rsbac_list_write_lol_buffers(): write error %i on device %02u:%02u file %s!\n", 04210 tmperr, 04211 RSBAC_MAJOR(write_item_p->device), 04212 RSBAC_MINOR(write_item_p->device), 04213 write_item_p->name); 04214 count = tmperr; 04215 goto out_free_all; 04216 } else 04217 count++; 04218 04219 rsbac_pr_debug(write, "%lu bytes from %u buffers written.\n", 04220 all_written, bufcount); 04221 free_buffers(write_item_p->buffer); 04222 next_item_p = write_item_p->next; 04223 rsbac_kfree(write_item_p); 04224 write_item_p = next_item_p; 04225 } 04226 /* Ready. */ 04227 rsbac_kfree(file_p); 04228 return count; 04229 04230 out_free_all: 04231 /* Mark unwritten lists dirty and free everything */ 04232 while(write_item_p) 04233 { 04234 if(write_item_p->list->self == write_item_p->list) 04235 write_item_p->list->dirty = TRUE; 04236 free_buffers(write_item_p->buffer); 04237 next_item_p = write_item_p->next; 04238 rsbac_kfree(write_item_p); 04239 write_item_p = next_item_p; 04240 } 04241 if(file_p) 04242 rsbac_kfree(file_p); 04243 return count; 04244 }
int rsbac_ta_list_add_ttl | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
rsbac_time_t | ttl, | |||
void * | desc, | |||
void * | data | |||
) |
Definition at line 6773 of file gen_lists.c.
References add_item(), rsbac_list_info_t::data_size, rsbac_list_reg_item_t::def_data, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::dirty, do_remove_item(), rsbac_list_reg_item_t::hash_function, rsbac_list_reg_item_t::hashed, rsbac_list_reg_item_t::info, list_initialized, rsbac_list_reg_head_t::lock, rsbac_list_reg_item_t::lock, lookup_item(), rsbac_list_item_t::max_age, rsbac_list_reg_item_t::nr_hashes, reg_head, RSBAC_EBUSY, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, RSBAC_LIST_MAX_AGE_LIMIT, RSBAC_LIST_TTL_KEEP, rsbac_ta_list_exist(), rsbac_list_reg_item_t::self, touch, and TRUE.
Referenced by rsbac_acl_add_group(), rsbac_acl_add_to_acl_entry(), rsbac_acl_change_group(), rsbac_acl_remove_from_acl_entry(), rsbac_acl_set_acl_entry(), rsbac_list_add(), rsbac_list_add_ttl(), rsbac_pm_add_target(), rsbac_pm_set_data(), rsbac_rc_copy_role(), rsbac_rc_copy_type(), rsbac_rc_set_item(), rsbac_um_add_group(), rsbac_um_mod_group(), rsbac_um_set_group_pass(), set_attr_dev(), set_attr_fd(), set_attr_ipc(), set_attr_process(), and set_attr_user().
06776 { 06777 struct rsbac_list_reg_item_t *list; 06778 struct rsbac_list_item_t *item_p; 06779 u_long lock_flags, rlock_flags; 06780 u_int hash = 0; 06781 06782 if (!handle) 06783 return -RSBAC_EINVALIDLIST; 06784 if (!desc) 06785 return -RSBAC_EINVALIDVALUE; 06786 if (!list_initialized) 06787 return -RSBAC_ENOTINITIALIZED; 06788 06789 list = (struct rsbac_list_reg_item_t *) handle; 06790 if (!list || (list->self != list)) 06791 return -RSBAC_EINVALIDLIST; 06792 06793 #ifdef CONFIG_RSBAC_LIST_TRANS 06794 if (ta_number && !rsbac_ta_list_exist(0, ta_handle, &ta_number)) 06795 return -RSBAC_EINVALIDTRANSACTION; 06796 #endif 06797 06798 rsbac_read_lock(®_head.lock, &rlock_flags); 06799 if (list->info.data_size && !data) { 06800 rsbac_read_unlock(®_head.lock, &rlock_flags); 06801 return -RSBAC_EINVALIDVALUE; 06802 } 06803 06804 /* 06805 rsbac_pr_debug(lists, "adding to list %s.\n", list->name); 06806 */ 06807 if (ttl && (ttl != RSBAC_LIST_TTL_KEEP)) { 06808 if (ttl > RSBAC_LIST_MAX_AGE_LIMIT) 06809 ttl = RSBAC_LIST_MAX_AGE_LIMIT; 06810 ttl += RSBAC_CURRENT_TIME; 06811 } 06812 rsbac_write_lock(&list->lock, &lock_flags); 06813 06814 if(list->hash_function) 06815 hash = list->hash_function(desc, list->nr_hashes); 06816 #ifdef CONFIG_RSBAC_LIST_TRANS 06817 if (!ta_number) 06818 #endif 06819 { 06820 item_p = lookup_item(list, desc); 06821 if (item_p) { /* exists -> update data, if any */ 06822 if (ttl != RSBAC_LIST_TTL_KEEP) 06823 item_p->max_age = ttl; 06824 if (data && list->info.data_size) { 06825 if (list->def_data 06826 && !item_p->max_age 06827 && !memcmp(list->def_data, data, 06828 list->info.data_size) 06829 ) 06830 do_remove_item(list, item_p, hash); 06831 else 06832 memcpy(((char *) item_p) + 06833 sizeof(*item_p) + 06834 list->info.desc_size, data, 06835 list->info.data_size); 06836 } 06837 } else { 06838 if (ttl == RSBAC_LIST_TTL_KEEP) 06839 ttl = 0; 06840 if (!list->def_data 06841 || memcmp(list->def_data, data, 06842 list->info.data_size) 06843 ) 06844 add_item(list, ttl, desc, data); 06845 } 06846 touch(list); 06847 list->dirty = TRUE; 06848 } 06849 #ifdef CONFIG_RSBAC_LIST_TRANS 06850 if (list->hashed[hash].ta_copied || ta_number) { 06851 if (!list->hashed[hash].ta_copied) 06852 ta_copy(ta_number, list, hash); 06853 else if (ta_number) { 06854 if (list->hashed[hash].ta_copied != ta_number) { 06855 rsbac_write_unlock(&list->lock, 06856 &lock_flags); 06857 rsbac_read_unlock(®_head.lock, 06858 &rlock_flags); 06859 return -RSBAC_EBUSY; 06860 } 06861 } else 06862 ta_number = list->hashed[hash].ta_copied; 06863 item_p = ta_lookup_item(ta_number, list, desc); 06864 if (item_p) { /* exists -> update data, if any */ 06865 if (ttl != RSBAC_LIST_TTL_KEEP) 06866 item_p->max_age = ttl; 06867 if (data && list->info.data_size) { 06868 if (list->def_data 06869 && !item_p->max_age 06870 && !memcmp(list->def_data, data, 06871 list->info.data_size) 06872 ) 06873 ta_do_remove_item(list, item_p, hash); 06874 else 06875 memcpy(((char *) item_p) + 06876 sizeof(*item_p) + 06877 list->info.desc_size, data, 06878 list->info.data_size); 06879 } 06880 } else { 06881 if (ttl == RSBAC_LIST_TTL_KEEP) 06882 ttl = 0; 06883 if (!list->def_data 06884 || memcmp(list->def_data, data, 06885 list->info.data_size) 06886 ) 06887 ta_add_item(ta_number, list, ttl, desc, 06888 data); 06889 } 06890 } 06891 #endif 06892 rsbac_write_unlock(&list->lock, &lock_flags); 06893 rsbac_read_unlock(®_head.lock, &rlock_flags); 06894 return 0; 06895 }
long rsbac_ta_list_count | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle | |||
) |
Definition at line 9107 of file gen_lists.c.
References rsbac_list_hashed_t::count, rsbac_list_reg_item_t::hashed, list_initialized, rsbac_list_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_reg_item_t::self.
Referenced by rsbac_list_count(), rsbac_rc_get_list(), rsbac_ta_list_all_dev(), rsbac_ta_list_all_group(), rsbac_ta_list_all_ipc(), rsbac_ta_list_all_user(), and rsbac_um_get_group_list().
09109 { 09110 struct rsbac_list_reg_item_t *list; 09111 long result = 0; 09112 int i; 09113 09114 if (!handle) 09115 return -RSBAC_EINVALIDLIST; 09116 if (!list_initialized) 09117 return -RSBAC_ENOTINITIALIZED; 09118 09119 list = (struct rsbac_list_reg_item_t *) handle; 09120 if (list->self != list) 09121 return -RSBAC_EINVALIDLIST; 09122 09123 #ifdef CONFIG_RSBAC_LIST_TRANS 09124 if (ta_number) { 09125 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 09126 return -RSBAC_EINVALIDTRANSACTION; 09127 } 09128 #endif 09129 09130 for (i=0; i<list->nr_hashes; i++) { 09131 #ifdef CONFIG_RSBAC_LIST_TRANS 09132 if (ta_number && (list->hashed[i].ta_copied == ta_number)) 09133 result += list->hashed[i].ta_count; 09134 else 09135 #endif 09136 result += list->hashed[i].count; 09137 } 09138 return result; 09139 }
int rsbac_ta_list_exist | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void * | desc | |||
) |
Definition at line 8707 of file gen_lists.c.
References FALSE, rsbac_list_reg_item_t::hash_function, rsbac_list_reg_item_t::hashed, list_initialized, rsbac_list_reg_head_t::lock, rsbac_list_reg_item_t::lock, lookup_item(), rsbac_list_item_t::max_age, rsbac_list_reg_item_t::nr_hashes, reg_head, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, rsbac_ta_list_exist(), rsbac_list_reg_item_t::self, and TRUE.
Referenced by rsbac_acl_add_group(), rsbac_acl_add_group_member(), rsbac_acl_change_group(), rsbac_acl_get_group_members(), rsbac_acl_group_exist(), rsbac_acl_remove_group_member(), rsbac_list_copy(), rsbac_list_exist(), rsbac_list_lol_copy(), rsbac_pm_exists(), rsbac_rc_role_exists(), rsbac_rc_set_item(), rsbac_rc_type_exists(), rsbac_ta_list_add_ttl(), rsbac_ta_list_all_dev(), rsbac_ta_list_count(), rsbac_ta_list_exist(), rsbac_ta_list_get_all_data(), rsbac_ta_list_get_all_desc(), rsbac_ta_list_get_all_items_ttl(), rsbac_ta_list_get_data_ttl(), rsbac_ta_list_get_desc(), rsbac_ta_list_get_max_desc(), rsbac_ta_list_get_next_desc(), rsbac_ta_list_lol_add_ttl(), rsbac_ta_list_lol_all_subcount(), rsbac_ta_list_lol_count(), rsbac_ta_list_lol_exist(), rsbac_ta_list_lol_get_all_data(), rsbac_ta_list_lol_get_all_desc(), rsbac_ta_list_lol_get_all_items(), rsbac_ta_list_lol_get_all_subdata(), rsbac_ta_list_lol_get_all_subdesc_ttl(), rsbac_ta_list_lol_get_all_subitems_ttl(), rsbac_ta_list_lol_get_data_ttl(), rsbac_ta_list_lol_get_desc(), rsbac_ta_list_lol_get_max_subdesc(), rsbac_ta_list_lol_get_next_desc(), rsbac_ta_list_lol_get_subdata_ttl(), rsbac_ta_list_lol_remove(), rsbac_ta_list_lol_remove_all(), rsbac_ta_list_lol_subadd_ttl(), rsbac_ta_list_lol_subcount(), rsbac_ta_list_lol_subexist(), rsbac_ta_list_lol_subexist_compare(), rsbac_ta_list_lol_subremove(), rsbac_ta_list_lol_subremove_all(), rsbac_ta_list_lol_subremove_count(), rsbac_ta_list_lol_subremove_from_all(), rsbac_ta_list_remove(), rsbac_ta_list_remove_all(), rsbac_um_add_gm(), rsbac_um_add_group(), rsbac_um_add_user(), rsbac_um_get_gm_user_list(), rsbac_um_get_group_item(), rsbac_um_group_exists(), rsbac_um_mod_group(), rsbac_um_mod_user(), and rsbac_um_remove_group().
08709 { 08710 struct rsbac_list_reg_item_t *list; 08711 u_long lock_flags, rlock_flags; 08712 struct rsbac_list_item_t *item_p; 08713 int result; 08714 #ifdef CONFIG_RSBAC_LIST_TRANS 08715 u_int hash = 0; 08716 #endif 08717 08718 if (!handle || !desc) 08719 return FALSE; 08720 if (!list_initialized) 08721 return FALSE; 08722 08723 list = (struct rsbac_list_reg_item_t *) handle; 08724 if (list->self != list) 08725 return -RSBAC_EINVALIDLIST; 08726 08727 #ifdef CONFIG_RSBAC_LIST_TRANS 08728 if (ta_number) { 08729 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 08730 return -RSBAC_EINVALIDTRANSACTION; 08731 if(list->hash_function) 08732 hash = list->hash_function(desc, list->nr_hashes); 08733 } 08734 #endif 08735 08736 rsbac_read_lock(®_head.lock, &rlock_flags); 08737 /* 08738 rsbac_pr_debug(lists, "testing on list %s.\n", list->name); 08739 */ 08740 rsbac_read_lock(&list->lock, &lock_flags); 08741 08742 #ifdef CONFIG_RSBAC_LIST_TRANS 08743 if (ta_number && (list->hashed[hash].ta_copied == ta_number)) 08744 item_p = ta_lookup_item(ta_number, list, desc); 08745 else 08746 #endif 08747 item_p = lookup_item(list, desc); 08748 if (item_p 08749 && (!item_p->max_age || (item_p->max_age > RSBAC_CURRENT_TIME) 08750 ) 08751 ) { /* exists -> TRUE */ 08752 result = TRUE; 08753 } else { 08754 result = FALSE; 08755 } 08756 rsbac_read_unlock(&list->lock, &lock_flags); 08757 rsbac_read_unlock(®_head.lock, &rlock_flags); 08758 return result; 08759 }
long rsbac_ta_list_get_all_data | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void ** | array_p | |||
) |
Definition at line 9443 of file gen_lists.c.
References rsbac_list_hashed_t::count, rsbac_list_info_t::data_size, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::hashed, rsbac_list_hashed_t::head, rsbac_list_reg_item_t::info, list_initialized, rsbac_list_reg_head_t::lock, rsbac_list_reg_item_t::lock, rsbac_list_item_t::max_age, rsbac_list_item_t::next, rsbac_list_reg_item_t::nr_hashes, NULL, reg_head, RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDREQUEST, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTINITIALIZED, RSBAC_MAX_KMALLOC, rsbac_ta_list_exist(), rsbac_vmalloc, and rsbac_list_reg_item_t::self.
Referenced by rsbac_acl_list_groups(), rsbac_acl_remove_user(), and rsbac_list_get_all_data().
09445 { 09446 struct rsbac_list_reg_item_t *list; 09447 struct rsbac_list_item_t *item_p; 09448 char *buffer; 09449 u_long lock_flags, rlock_flags; 09450 u_long offset = 0; 09451 long result = 0; 09452 u_int item_size; 09453 u_int item_offset; 09454 int i; 09455 u_long count = 0; 09456 09457 if (!handle) 09458 return -RSBAC_EINVALIDLIST; 09459 if (!array_p) 09460 return -RSBAC_EINVALIDPOINTER; 09461 if (!list_initialized) 09462 return -RSBAC_ENOTINITIALIZED; 09463 09464 list = (struct rsbac_list_reg_item_t *) handle; 09465 if (list->self != list) 09466 return -RSBAC_EINVALIDLIST; 09467 *array_p = NULL; 09468 09469 #ifdef CONFIG_RSBAC_LIST_TRANS 09470 if (ta_number) { 09471 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 09472 return -RSBAC_EINVALIDTRANSACTION; 09473 } 09474 #endif 09475 09476 rsbac_read_lock(®_head.lock, &rlock_flags); 09477 /* 09478 rsbac_pr_debug(lists, "list %s.\n", list->name); 09479 */ 09480 rsbac_read_lock(&list->lock, &lock_flags); 09481 if (!list->info.data_size) { 09482 rsbac_read_unlock(&list->lock, &lock_flags); 09483 rsbac_read_unlock(®_head.lock, &rlock_flags); 09484 return -RSBAC_EINVALIDREQUEST; 09485 } 09486 for (i=0; i<list->nr_hashes; i++) { 09487 #ifdef CONFIG_RSBAC_LIST_TRANS 09488 if (ta_number && (list->hashed[i].ta_copied == ta_number)) 09489 count += list->hashed[i].ta_count; 09490 else 09491 #endif 09492 count += list->hashed[i].count; 09493 } 09494 if(!count) { 09495 result = 0; 09496 goto out_unlock; 09497 } 09498 item_size = list->info.data_size; 09499 item_offset = list->info.desc_size; 09500 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 09501 if(count > RSBAC_MAX_KMALLOC / item_size) 09502 count = RSBAC_MAX_KMALLOC / item_size; 09503 #endif 09504 buffer = rsbac_vmalloc(item_size * count); 09505 if (!buffer) { 09506 result = -ENOMEM; 09507 goto out_unlock; 09508 } 09509 for (i=0; i<list->nr_hashes; i++) { 09510 #ifdef CONFIG_RSBAC_LIST_TRANS 09511 if (ta_number && (list->hashed[i].ta_copied == ta_number)) 09512 item_p = list->hashed[i].ta_head; 09513 else 09514 #endif 09515 item_p = list->hashed[i].head; 09516 while (item_p && (result < count)) { 09517 if (!item_p->max_age 09518 || (item_p->max_age > 09519 RSBAC_CURRENT_TIME) 09520 ) { 09521 memcpy(buffer + offset, 09522 ((char *) item_p) + 09523 sizeof(*item_p) + 09524 item_offset, item_size); 09525 offset += item_size; 09526 result++; 09527 } 09528 item_p = item_p->next; 09529 } 09530 } 09531 *array_p = buffer; 09532 09533 out_unlock: 09534 rsbac_read_unlock(&list->lock, &lock_flags); 09535 rsbac_read_unlock(®_head.lock, &rlock_flags); 09536 return result; 09537 }
long rsbac_ta_list_get_all_desc | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void ** | array_p | |||
) |
Definition at line 9150 of file gen_lists.c.
References rsbac_list_hashed_t::count, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::hashed, rsbac_list_hashed_t::head, rsbac_list_reg_item_t::info, list_initialized, rsbac_list_reg_head_t::lock, rsbac_list_reg_item_t::lock, rsbac_list_item_t::max_age, rsbac_list_item_t::next, rsbac_list_reg_item_t::nr_hashes, NULL, reg_head, RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTINITIALIZED, RSBAC_MAX_KMALLOC, rsbac_ta_list_exist(), rsbac_vmalloc, and rsbac_list_reg_item_t::self.
Referenced by copy_new_ipcs(), copy_new_uids(), rsbac_list_get_all_desc(), rsbac_rc_copy_type(), rsbac_rc_get_list(), rsbac_ta_list_all_dev(), rsbac_ta_list_all_group(), rsbac_ta_list_all_user(), and rsbac_um_get_group_list().
09152 { 09153 struct rsbac_list_reg_item_t *list; 09154 struct rsbac_list_item_t *item_p; 09155 char *buffer; 09156 u_long lock_flags, rlock_flags; 09157 u_long offset = 0; 09158 u_long count = 0; 09159 long result = 0; 09160 u_int item_size; 09161 int i; 09162 09163 if (!handle) 09164 return -RSBAC_EINVALIDLIST; 09165 if (!array_p) 09166 return -RSBAC_EINVALIDPOINTER; 09167 if (!list_initialized) 09168 return -RSBAC_ENOTINITIALIZED; 09169 09170 list = (struct rsbac_list_reg_item_t *) handle; 09171 if (list->self != list) 09172 return -RSBAC_EINVALIDLIST; 09173 *array_p = NULL; 09174 09175 #ifdef CONFIG_RSBAC_LIST_TRANS 09176 if (ta_number) { 09177 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 09178 return -RSBAC_EINVALIDTRANSACTION; 09179 } 09180 #endif 09181 09182 rsbac_read_lock(®_head.lock, &rlock_flags); 09183 /* 09184 rsbac_pr_debug(lists, "list %s.\n", list->name); 09185 */ 09186 rsbac_read_lock(&list->lock, &lock_flags); 09187 for (i=0; i<list->nr_hashes; i++) { 09188 #ifdef CONFIG_RSBAC_LIST_TRANS 09189 if (ta_number && (list->hashed[i].ta_copied == ta_number)) 09190 count += list->hashed[i].ta_count; 09191 else 09192 #endif 09193 count += list->hashed[i].count; 09194 } 09195 if(!count) { 09196 result = 0; 09197 goto out_unlock; 09198 } 09199 item_size = list->info.desc_size; 09200 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 09201 if(count > RSBAC_MAX_KMALLOC / item_size) 09202 count = RSBAC_MAX_KMALLOC / item_size; 09203 #endif 09204 buffer = rsbac_vmalloc(item_size * count); 09205 if (!buffer) { 09206 result = -ENOMEM; 09207 goto out_unlock; 09208 } 09209 for (i=0; i<list->nr_hashes; i++) { 09210 #ifdef CONFIG_RSBAC_LIST_TRANS 09211 if (ta_number && (list->hashed[i].ta_copied == ta_number)) 09212 item_p = list->hashed[i].ta_head; 09213 else 09214 #endif 09215 item_p = list->hashed[i].head; 09216 while (item_p && (result < count)) { 09217 if (!item_p->max_age 09218 || (item_p->max_age > 09219 RSBAC_CURRENT_TIME) 09220 ) { 09221 memcpy(buffer + offset, 09222 ((char *) item_p) + 09223 sizeof(*item_p), item_size); 09224 offset += item_size; 09225 result++; 09226 } 09227 item_p = item_p->next; 09228 } 09229 } 09230 *array_p = buffer; 09231 09232 out_unlock: 09233 rsbac_read_unlock(&list->lock, &lock_flags); 09234 rsbac_read_unlock(®_head.lock, &rlock_flags); 09235 return result; 09236 }
long rsbac_ta_list_get_all_items_ttl | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void ** | array_p, | |||
rsbac_time_t ** | ttl_array_p | |||
) |
Definition at line 9797 of file gen_lists.c.
References rsbac_list_hashed_t::count, rsbac_list_info_t::data_size, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::hashed, rsbac_list_hashed_t::head, rsbac_list_reg_item_t::info, list_initialized, rsbac_list_reg_head_t::lock, rsbac_list_reg_item_t::lock, rsbac_list_item_t::max_age, rsbac_list_item_t::next, rsbac_list_reg_item_t::nr_hashes, NULL, reg_head, RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTINITIALIZED, RSBAC_MAX_KMALLOC, rsbac_ta_list_exist(), rsbac_vfree, rsbac_vmalloc, and rsbac_list_reg_item_t::self.
Referenced by rsbac_acl_get_tlist(), rsbac_list_get_all_items(), and rsbac_list_get_all_items_ttl().
09801 { 09802 struct rsbac_list_reg_item_t *list; 09803 struct rsbac_list_item_t *item_p; 09804 char *buffer; 09805 rsbac_time_t *ttl_p = NULL; 09806 u_long lock_flags, rlock_flags; 09807 u_long offset = 0; 09808 long result = 0; 09809 u_int item_size; 09810 int i; 09811 u_long count = 0; 09812 09813 if (!handle) 09814 return -RSBAC_EINVALIDLIST; 09815 if (!array_p) 09816 return -RSBAC_EINVALIDPOINTER; 09817 if (!list_initialized) 09818 return -RSBAC_ENOTINITIALIZED; 09819 09820 list = (struct rsbac_list_reg_item_t *) handle; 09821 if (list->self != list) 09822 return -RSBAC_EINVALIDLIST; 09823 *array_p = NULL; 09824 09825 #ifdef CONFIG_RSBAC_LIST_TRANS 09826 if (ta_number) { 09827 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 09828 return -RSBAC_EINVALIDTRANSACTION; 09829 } 09830 #endif 09831 09832 rsbac_read_lock(®_head.lock, &rlock_flags); 09833 /* 09834 rsbac_pr_debug(lists, "list %s.\n", list->name); 09835 */ 09836 rsbac_read_lock(&list->lock, &lock_flags); 09837 for (i=0; i<list->nr_hashes; i++) { 09838 #ifdef CONFIG_RSBAC_LIST_TRANS 09839 if (ta_number && (list->hashed[i].ta_copied == ta_number)) 09840 count += list->hashed[i].ta_count; 09841 else 09842 #endif 09843 count += list->hashed[i].count; 09844 } 09845 if(!count) { 09846 result = 0; 09847 goto out_unlock; 09848 } 09849 item_size = list->info.desc_size + list->info.data_size; 09850 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 09851 if(count > RSBAC_MAX_KMALLOC / item_size) 09852 count = RSBAC_MAX_KMALLOC / item_size; 09853 #endif 09854 buffer = rsbac_vmalloc(item_size * count); 09855 if (!buffer) { 09856 result = -ENOMEM; 09857 goto out_unlock; 09858 } 09859 if (ttl_array_p) { 09860 ttl_p = rsbac_vmalloc(sizeof(**ttl_array_p) * count); 09861 if (!ttl_p) { 09862 result = -ENOMEM; 09863 rsbac_vfree(buffer); 09864 goto out_unlock; 09865 } 09866 } 09867 for (i=0; i<list->nr_hashes; i++) { 09868 #ifdef CONFIG_RSBAC_LIST_TRANS 09869 if (ta_number && (list->hashed[i].ta_copied == ta_number)) 09870 item_p = list->hashed[i].ta_head; 09871 else 09872 #endif 09873 item_p = list->hashed[i].head; 09874 while (item_p && (result < count)) { 09875 if (!item_p->max_age 09876 || (item_p->max_age > 09877 RSBAC_CURRENT_TIME) 09878 ) { 09879 memcpy(buffer + offset, 09880 ((char *) item_p) + 09881 sizeof(*item_p), item_size); 09882 if (ttl_p) { 09883 if (item_p->max_age) 09884 ttl_p[result] = 09885 item_p->max_age - RSBAC_CURRENT_TIME; 09886 else 09887 ttl_p[result] = 0; 09888 } 09889 offset += item_size; 09890 result++; 09891 } 09892 item_p = item_p->next; 09893 } 09894 } 09895 *array_p = buffer; 09896 if (ttl_array_p) 09897 *ttl_array_p = ttl_p; 09898 09899 out_unlock: 09900 rsbac_read_unlock(&list->lock, &lock_flags); 09901 rsbac_read_unlock(®_head.lock, &rlock_flags); 09902 return result; 09903 }
int rsbac_ta_list_get_data_ttl | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
rsbac_time_t * | ttl_p, | |||
void * | desc, | |||
void * | data | |||
) |
Definition at line 7996 of file gen_lists.c.
References rsbac_list_info_t::data_size, rsbac_list_reg_item_t::def_data, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::hash_function, rsbac_list_reg_item_t::hashed, rsbac_list_reg_item_t::info, list_initialized, rsbac_list_reg_head_t::lock, rsbac_list_reg_item_t::lock, lookup_item(), rsbac_list_item_t::max_age, rsbac_list_reg_item_t::nr_hashes, reg_head, RSBAC_EINVALIDLIST, RSBAC_EINVALIDREQUEST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_reg_item_t::self.
Referenced by get_attr_dev(), get_attr_fd(), get_attr_ipc(), get_attr_process(), get_attr_user(), rsbac_acl_add_to_acl_entry(), rsbac_acl_get_group_entry(), rsbac_acl_get_rights(), rsbac_acl_get_single_right(), rsbac_acl_remove_from_acl_entry(), rsbac_list_get_data(), rsbac_list_get_data_ttl(), rsbac_pm_exists(), rsbac_pm_get_all_data(), rsbac_pm_get_data(), rsbac_pm_set_data(), rsbac_rc_copy_role(), rsbac_rc_copy_type(), rsbac_rc_get_item(), rsbac_rc_set_item(), rsbac_um_get_group_item(), rsbac_um_mod_group(), rsbac_um_set_group_pass(), set_attr_dev(), set_attr_fd(), set_attr_ipc(), set_attr_process(), and set_attr_user().
08000 { 08001 struct rsbac_list_reg_item_t *list; 08002 struct rsbac_list_item_t *item_p; 08003 u_long lock_flags, rlock_flags; 08004 int err = 0; 08005 #ifdef CONFIG_RSBAC_LIST_TRANS 08006 u_int hash = 0; 08007 #endif 08008 08009 if (!handle) 08010 return -RSBAC_EINVALIDLIST; 08011 if (!desc) 08012 return -RSBAC_EINVALIDVALUE; 08013 if (!list_initialized) 08014 return -RSBAC_ENOTINITIALIZED; 08015 08016 list = (struct rsbac_list_reg_item_t *) handle; 08017 if (list->self != list) 08018 return -RSBAC_EINVALIDLIST; 08019 08020 #ifdef CONFIG_RSBAC_LIST_TRANS 08021 if (ta_number) { 08022 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 08023 return -RSBAC_EINVALIDTRANSACTION; 08024 if(list->hash_function) 08025 hash = list->hash_function(desc, list->nr_hashes); 08026 } 08027 #endif 08028 08029 rsbac_read_lock(®_head.lock, &rlock_flags); 08030 /* 08031 rsbac_pr_debug(lists, "getting data from list %s.\n", 08032 list->name); 08033 */ 08034 if (data && !list->info.data_size) { 08035 rsbac_read_unlock(®_head.lock, &rlock_flags); 08036 return -RSBAC_EINVALIDREQUEST; 08037 } 08038 08039 rsbac_read_lock(&list->lock, &lock_flags); 08040 #ifdef CONFIG_RSBAC_LIST_TRANS 08041 if (ta_number && (list->hashed[hash].ta_copied == ta_number)) 08042 item_p = ta_lookup_item(ta_number, list, desc); 08043 else 08044 #endif 08045 item_p = lookup_item(list, desc); 08046 if (item_p 08047 && (!item_p->max_age || (item_p->max_age > RSBAC_CURRENT_TIME) 08048 ) 08049 ) { /* exists -> copy data, if any */ 08050 if (ttl_p) { 08051 if (item_p->max_age) 08052 *ttl_p = 08053 item_p->max_age - RSBAC_CURRENT_TIME; 08054 else 08055 *ttl_p = 0; 08056 } 08057 if (data) { 08058 memcpy(data, 08059 ((char *) item_p) + sizeof(*item_p) + 08060 list->info.desc_size, list->info.data_size); 08061 } 08062 } else { 08063 if (!list->def_data) 08064 err = -RSBAC_ENOTFOUND; 08065 else { 08066 if (ttl_p) 08067 *ttl_p = 0; 08068 if (data) 08069 memcpy(data, 08070 list->def_data, 08071 list->info.data_size); 08072 } 08073 } 08074 rsbac_read_unlock(&list->lock, &lock_flags); 08075 rsbac_read_unlock(®_head.lock, &rlock_flags); 08076 return err; 08077 }
int rsbac_ta_list_get_desc | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void * | desc, | |||
void * | data, | |||
rsbac_list_data_compare_function_t | compare | |||
) |
Definition at line 8586 of file gen_lists.c.
References rsbac_list_info_t::data_size, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::info, list_initialized, rsbac_list_reg_head_t::lock, rsbac_list_reg_item_t::lock, lookup_item_data(), reg_head, RSBAC_EINVALIDLIST, RSBAC_EINVALIDREQUEST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_reg_item_t::self.
Referenced by rsbac_list_get_desc(), and rsbac_um_get_gid().
08591 { 08592 struct rsbac_list_reg_item_t *list; 08593 struct rsbac_list_item_t *item_p; 08594 u_long lock_flags, rlock_flags; 08595 int err = 0; 08596 08597 if (!handle) 08598 return -RSBAC_EINVALIDLIST; 08599 if (!desc || !data) 08600 return -RSBAC_EINVALIDVALUE; 08601 if (!list_initialized) 08602 return -RSBAC_ENOTINITIALIZED; 08603 08604 list = (struct rsbac_list_reg_item_t *) handle; 08605 if (list->self != list) 08606 return -RSBAC_EINVALIDLIST; 08607 08608 #ifdef CONFIG_RSBAC_LIST_TRANS 08609 if (ta_number) { 08610 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 08611 return -RSBAC_EINVALIDTRANSACTION; 08612 } 08613 #endif 08614 08615 rsbac_read_lock(®_head.lock, &rlock_flags); 08616 /* 08617 rsbac_pr_debug(lists, "getting desc from list %s.\n", list->name); 08618 */ 08619 if (!list->info.data_size) { 08620 rsbac_read_unlock(®_head.lock, &rlock_flags); 08621 return -RSBAC_EINVALIDREQUEST; 08622 } 08623 08624 rsbac_read_lock(&list->lock, &lock_flags); 08625 08626 #ifdef CONFIG_RSBAC_LIST_TRANS 08627 item_p = ta_lookup_item_data(ta_number, list, data, compare); 08628 #else 08629 item_p = lookup_item_data(list, data, compare); 08630 #endif 08631 if (item_p) { /* exists -> copy desc */ 08632 memcpy(desc, 08633 ((char *) item_p) + sizeof(*item_p), 08634 list->info.desc_size); 08635 } else { 08636 err = -RSBAC_ENOTFOUND; 08637 } 08638 rsbac_read_unlock(&list->lock, &lock_flags); 08639 rsbac_read_unlock(®_head.lock, &rlock_flags); 08640 return err; 08641 }
int rsbac_ta_list_get_max_desc | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void * | desc | |||
) |
Definition at line 8347 of file gen_lists.c.
References rsbac_list_reg_item_t::compare, rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::hashed, rsbac_list_reg_item_t::info, list_initialized, rsbac_list_reg_head_t::lock, rsbac_list_reg_item_t::lock, rsbac_list_item_t::max_age, rsbac_list_reg_item_t::nr_hashes, NULL, rsbac_list_item_t::prev, reg_head, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), rsbac_list_reg_item_t::self, and rsbac_list_hashed_t::tail.
Referenced by rsbac_list_get_max_desc().
08349 { 08350 struct rsbac_list_reg_item_t *list; 08351 struct rsbac_list_item_t *item_p = NULL; 08352 struct rsbac_list_item_t *tmp_item_p; 08353 u_long lock_flags, rlock_flags; 08354 int err = 0; 08355 int i; 08356 08357 if (!handle) 08358 return -RSBAC_EINVALIDLIST; 08359 if (!list_initialized) 08360 return -RSBAC_ENOTINITIALIZED; 08361 08362 list = (struct rsbac_list_reg_item_t *) handle; 08363 if (list->self != list) 08364 return -RSBAC_EINVALIDLIST; 08365 08366 #ifdef CONFIG_RSBAC_LIST_TRANS 08367 if (ta_number) { 08368 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 08369 return -RSBAC_EINVALIDTRANSACTION; 08370 } 08371 #endif 08372 08373 rsbac_read_lock(®_head.lock, &rlock_flags); 08374 /* 08375 rsbac_pr_debug(lists, "list %s.\n", list->name); 08376 */ 08377 rsbac_read_lock(&list->lock, &lock_flags); 08378 for (i=0; i<list->nr_hashes; i++) { 08379 #ifdef CONFIG_RSBAC_LIST_TRANS 08380 if (ta_number && (list->hashed[i].ta_copied == ta_number)) 08381 tmp_item_p = list->hashed[i].ta_tail; 08382 else 08383 #endif 08384 tmp_item_p = list->hashed[i].tail; 08385 while (tmp_item_p 08386 && tmp_item_p->max_age && (tmp_item_p->max_age > RSBAC_CURRENT_TIME) 08387 ) 08388 tmp_item_p = tmp_item_p->prev; 08389 if(tmp_item_p) { 08390 if(list->compare) { 08391 if(!item_p || list->compare(&tmp_item_p[1], &item_p[1]) > 0) 08392 item_p = tmp_item_p; 08393 } else { 08394 if(!item_p || memcmp(&tmp_item_p[1], &item_p[1], list->info.desc_size) > 0) 08395 item_p = tmp_item_p; 08396 } 08397 } 08398 } 08399 if (item_p) 08400 memcpy(desc, (char *) item_p + sizeof(*item_p), 08401 list->info.desc_size); 08402 else { 08403 memset(desc, 0, list->info.desc_size); 08404 err = -RSBAC_ENOTFOUND; 08405 } 08406 rsbac_read_unlock(&list->lock, &lock_flags); 08407 rsbac_read_unlock(®_head.lock, &rlock_flags); 08408 return err; 08409 }
int rsbac_ta_list_get_next_desc | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void * | old_desc, | |||
void * | next_desc | |||
) |
Definition at line 8414 of file gen_lists.c.
References rsbac_list_info_t::desc_size, rsbac_list_reg_item_t::hash_function, rsbac_list_reg_item_t::hashed, rsbac_list_hashed_t::head, rsbac_list_reg_item_t::info, list_initialized, rsbac_list_reg_head_t::lock, rsbac_list_reg_item_t::lock, lookup_item(), rsbac_list_item_t::max_age, rsbac_list_item_t::next, rsbac_list_reg_item_t::nr_hashes, NULL, reg_head, RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_reg_item_t::self.
Referenced by rsbac_list_get_next_desc().
08417 { 08418 struct rsbac_list_reg_item_t *list; 08419 struct rsbac_list_item_t *item_p; 08420 u_long lock_flags, rlock_flags; 08421 u_int hash = 0; 08422 08423 if (!handle) 08424 return -RSBAC_EINVALIDLIST; 08425 if (!list_initialized) 08426 return -RSBAC_ENOTINITIALIZED; 08427 if (!next_desc) 08428 return -RSBAC_EINVALIDPOINTER; 08429 08430 list = (struct rsbac_list_reg_item_t *) handle; 08431 if (list->self != list) 08432 return -RSBAC_EINVALIDLIST; 08433 08434 #ifdef CONFIG_RSBAC_LIST_TRANS 08435 if (ta_number) { 08436 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 08437 return -RSBAC_EINVALIDTRANSACTION; 08438 } 08439 #endif 08440 08441 rsbac_read_lock(®_head.lock, &rlock_flags); 08442 /* 08443 rsbac_pr_debug(lists, "list %s.\n", list->name); 08444 */ 08445 rsbac_read_lock(&list->lock, &lock_flags); 08446 if (old_desc) { 08447 if(list->hash_function) 08448 hash = list->hash_function(old_desc, list->nr_hashes); 08449 #ifdef CONFIG_RSBAC_LIST_TRANS 08450 if (ta_number && (list->hashed[hash].ta_copied == ta_number)) 08451 item_p = ta_lookup_item(ta_number, list, old_desc); 08452 else 08453 #endif 08454 item_p = lookup_item(list, old_desc); 08455 if(item_p) { 08456 item_p = item_p->next; 08457 while (item_p 08458 && item_p->max_age && (item_p->max_age > RSBAC_CURRENT_TIME) 08459 ) { 08460 item_p = item_p->next; 08461 } 08462 hash++; 08463 } else 08464 hash = 0; 08465 } else 08466 item_p = NULL; 08467 while (!item_p && (hash < list->nr_hashes)) { 08468 #ifdef CONFIG_RSBAC_LIST_TRANS 08469 if (ta_number && (list->hashed[hash].ta_copied == ta_number)) 08470 item_p = list->hashed[hash].ta_head; 08471 else 08472 #endif 08473 item_p = list->hashed[hash].head; 08474 while (item_p 08475 && item_p->max_age && (item_p->max_age > RSBAC_CURRENT_TIME) 08476 ) { 08477 item_p = item_p->next; 08478 } 08479 hash++; 08480 } 08481 if (item_p) { 08482 memcpy(next_desc, (char *) item_p + sizeof(*item_p), 08483 list->info.desc_size); 08484 } 08485 rsbac_read_unlock(&list->lock, &lock_flags); 08486 rsbac_read_unlock(®_head.lock, &rlock_flags); 08487 if (item_p) 08488 return 0; 08489 else 08490 return -RSBAC_ENOTFOUND; 08491 }
int rsbac_ta_list_lol_add_ttl | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
rsbac_time_t | ttl, | |||
void * | desc, | |||
void * | data | |||
) |
Definition at line 7114 of file gen_lists.c.
References add_lol_item(), rsbac_list_lol_item_t::count, rsbac_list_lol_info_t::data_size, rsbac_list_lol_reg_item_t::def_data, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::dirty, do_remove_lol_item(), rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, lol_touch, lookup_lol_item(), rsbac_list_lol_item_t::max_age, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EBUSY, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, RSBAC_LIST_MAX_AGE_LIMIT, RSBAC_LIST_TTL_KEEP, rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, and TRUE.
Referenced by rsbac_acl_add_group_member(), rsbac_acl_add_to_acl_entry(), rsbac_acl_set_acl_entry(), rsbac_acl_set_mask(), rsbac_list_lol_add(), rsbac_list_lol_add_ttl(), rsbac_pm_create_set(), rsbac_um_add_user(), rsbac_um_mod_user(), and rsbac_um_set_pass().
07117 { 07118 struct rsbac_list_lol_reg_item_t *list; 07119 struct rsbac_list_lol_item_t *item_p; 07120 u_long lock_flags, rlock_flags; 07121 u_int hash = 0; 07122 07123 if (!handle) 07124 return -RSBAC_EINVALIDLIST; 07125 if (!desc) 07126 return -RSBAC_EINVALIDVALUE; 07127 if (!list_initialized) 07128 return -RSBAC_ENOTINITIALIZED; 07129 07130 list = (struct rsbac_list_lol_reg_item_t *) handle; 07131 if (!list || (list->self != list)) 07132 return -RSBAC_EINVALIDLIST; 07133 07134 #ifdef CONFIG_RSBAC_LIST_TRANS 07135 if (ta_number && !rsbac_ta_list_exist(0, ta_handle, &ta_number)) 07136 return -RSBAC_EINVALIDTRANSACTION; 07137 #endif 07138 07139 if (ttl && (ttl != RSBAC_LIST_TTL_KEEP)) { 07140 if (ttl > RSBAC_LIST_MAX_AGE_LIMIT) 07141 ttl = RSBAC_LIST_MAX_AGE_LIMIT; 07142 ttl += RSBAC_CURRENT_TIME; 07143 } 07144 07145 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 07146 if (list->info.data_size && !data) { 07147 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 07148 return -RSBAC_EINVALIDVALUE; 07149 } 07150 07151 /* 07152 rsbac_pr_debug(lists, "adding to list %s.\n", list->name); 07153 */ 07154 rsbac_write_lock(&list->lock, &lock_flags); 07155 07156 if(list->hash_function) 07157 hash = list->hash_function(desc, list->nr_hashes); 07158 #ifdef CONFIG_RSBAC_LIST_TRANS 07159 if (!ta_number) 07160 #endif 07161 { 07162 item_p = lookup_lol_item(list, desc); 07163 if (item_p) { /* exists -> update data, if any */ 07164 if (ttl != RSBAC_LIST_TTL_KEEP) 07165 item_p->max_age = ttl; 07166 if (data && list->info.data_size) { 07167 if (list->def_data 07168 && !item_p->max_age 07169 && !memcmp(list->def_data, data, 07170 list->info.data_size) 07171 && !item_p->count) 07172 do_remove_lol_item(list, item_p, hash); 07173 else 07174 memcpy(((char *) item_p) + 07175 sizeof(*item_p) + 07176 list->info.desc_size, data, 07177 list->info.data_size); 07178 } 07179 } else { 07180 if (ttl == RSBAC_LIST_TTL_KEEP) 07181 ttl = 0; 07182 if (!list->def_data 07183 || memcmp(list->def_data, data, 07184 list->info.data_size) 07185 ) 07186 add_lol_item(list, ttl, desc, data); 07187 } 07188 lol_touch(list); 07189 list->dirty = TRUE; 07190 } 07191 #ifdef CONFIG_RSBAC_LIST_TRANS 07192 if (list->hashed[hash].ta_copied || ta_number) { 07193 if (!list->hashed[hash].ta_copied) 07194 ta_lol_copy(ta_number, list, hash); 07195 else if (ta_number) { 07196 if (list->hashed[hash].ta_copied != ta_number) { 07197 rsbac_write_unlock(&list->lock, 07198 &lock_flags); 07199 rsbac_read_unlock(&lol_reg_head.lock, 07200 &rlock_flags); 07201 return -RSBAC_EBUSY; 07202 } 07203 } else 07204 ta_number = list->hashed[hash].ta_copied; 07205 item_p = ta_lookup_lol_item(ta_number, list, desc); 07206 if (item_p) { /* exists -> update data, if any */ 07207 if (ttl != RSBAC_LIST_TTL_KEEP) 07208 item_p->max_age = ttl; 07209 if (data && list->info.data_size) { 07210 if (list->def_data 07211 && !item_p->max_age 07212 && !memcmp(list->def_data, data, 07213 list->info.data_size) 07214 && !item_p->count) 07215 ta_do_remove_lol_item(list, 07216 item_p, 07217 hash); 07218 else 07219 memcpy(((char *) item_p) + 07220 sizeof(*item_p) + 07221 list->info.desc_size, data, 07222 list->info.data_size); 07223 } 07224 } else { 07225 if (ttl == RSBAC_LIST_TTL_KEEP) 07226 ttl = 0; 07227 if (!list->def_data 07228 || memcmp(list->def_data, data, 07229 list->info.data_size) 07230 ) 07231 ta_add_lol_item(ta_number, list, ttl, desc, 07232 data); 07233 } 07234 } 07235 #endif 07236 rsbac_write_unlock(&list->lock, &lock_flags); 07237 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 07238 return 0; 07239 }
long rsbac_ta_list_lol_all_subcount | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle | |||
) |
Definition at line 9016 of file gen_lists.c.
References rsbac_list_lol_item_t::count, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_hashed_t::head, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_lol_reg_item_t::self.
Referenced by rsbac_list_lol_all_subcount().
09018 { 09019 struct rsbac_list_lol_reg_item_t *list; 09020 struct rsbac_list_lol_item_t *sublist; 09021 u_long lock_flags, rlock_flags; 09022 long result = 0; 09023 int i; 09024 09025 if (!handle) 09026 return -RSBAC_EINVALIDLIST; 09027 if (!list_initialized) 09028 return -RSBAC_ENOTINITIALIZED; 09029 09030 list = (struct rsbac_list_lol_reg_item_t *) handle; 09031 if (list->self != list) 09032 return -RSBAC_EINVALIDLIST; 09033 09034 #ifdef CONFIG_RSBAC_LIST_TRANS 09035 if (ta_number) { 09036 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 09037 return -RSBAC_EINVALIDTRANSACTION; 09038 } 09039 #endif 09040 09041 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 09042 /* 09043 rsbac_pr_debug(lists, "list %s.\n", list->name); 09044 */ 09045 rsbac_read_lock(&list->lock, &lock_flags); 09046 09047 for (i=0; i<list->nr_hashes; i++) { 09048 #ifdef CONFIG_RSBAC_LIST_TRANS 09049 if (ta_number && (list->hashed[i].ta_copied == ta_number)) 09050 sublist = list->hashed[i].ta_head; 09051 else 09052 #endif 09053 sublist = list->hashed[i].head; 09054 while (sublist) { 09055 result += sublist->count; 09056 sublist = sublist->next; 09057 } 09058 } 09059 rsbac_read_unlock(&list->lock, &lock_flags); 09060 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 09061 return result; 09062 }
long rsbac_ta_list_lol_count | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle | |||
) |
Definition at line 9067 of file gen_lists.c.
References rsbac_list_lol_hashed_t::count, rsbac_list_lol_reg_item_t::hashed, list_initialized, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_lol_reg_item_t::self.
Referenced by rsbac_acl_list_all_dev(), rsbac_acl_list_all_major_dev(), rsbac_acl_list_all_user(), rsbac_list_lol_count(), rsbac_um_get_gm_user_list(), and rsbac_um_get_user_list().
09069 { 09070 struct rsbac_list_lol_reg_item_t *list; 09071 long result = 0; 09072 int i; 09073 09074 if (!handle) 09075 return -RSBAC_EINVALIDLIST; 09076 if (!list_initialized) 09077 return -RSBAC_ENOTINITIALIZED; 09078 09079 list = (struct rsbac_list_lol_reg_item_t *) handle; 09080 if (list->self != list) 09081 return -RSBAC_EINVALIDLIST; 09082 09083 #ifdef CONFIG_RSBAC_LIST_TRANS 09084 if (ta_number) { 09085 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 09086 return -RSBAC_EINVALIDTRANSACTION; 09087 } 09088 #endif 09089 09090 /* 09091 rsbac_pr_debug(lists, "list %s.\n", list->name); 09092 */ 09093 for (i=0; i<list->nr_hashes; i++) { 09094 #ifdef CONFIG_RSBAC_LIST_TRANS 09095 if (ta_number && (list->hashed[i].ta_copied == ta_number)) 09096 result += list->hashed[i].ta_count; 09097 else 09098 #endif 09099 result += list->hashed[i].count; 09100 } 09101 return result; 09102 }
int rsbac_ta_list_lol_exist | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void * | desc | |||
) |
Definition at line 8903 of file gen_lists.c.
References FALSE, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, lookup_lol_item(), rsbac_list_lol_item_t::max_age, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, and TRUE.
Referenced by rsbac_acl_add_group_member(), rsbac_acl_add_to_acl_entry(), rsbac_acl_set_acl_entry(), rsbac_list_lol_exist(), rsbac_pm_create_set(), rsbac_pm_exists(), rsbac_pm_remove_target(), rsbac_pm_set_exist(), rsbac_um_add_user(), rsbac_um_get_user_item(), rsbac_um_mod_user(), rsbac_um_remove_user(), and rsbac_um_user_exists().
08905 { 08906 struct rsbac_list_lol_reg_item_t *list; 08907 u_long lock_flags, rlock_flags; 08908 struct rsbac_list_lol_item_t *item_p; 08909 int result; 08910 #ifdef CONFIG_RSBAC_LIST_TRANS 08911 u_int hash = 0; 08912 #endif 08913 08914 if (!handle || !desc) 08915 return FALSE; 08916 if (!list_initialized) 08917 return FALSE; 08918 08919 list = (struct rsbac_list_lol_reg_item_t *) handle; 08920 if (list->self != list) 08921 return -RSBAC_EINVALIDLIST; 08922 08923 #ifdef CONFIG_RSBAC_LIST_TRANS 08924 if (ta_number) { 08925 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 08926 return -RSBAC_EINVALIDTRANSACTION; 08927 if(list->hash_function) 08928 hash = list->hash_function(desc, list->nr_hashes); 08929 } 08930 #endif 08931 08932 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 08933 /* 08934 rsbac_pr_debug(lists, "testing on list %s.\n", list->name); 08935 */ 08936 rsbac_read_lock(&list->lock, &lock_flags); 08937 08938 #ifdef CONFIG_RSBAC_LIST_TRANS 08939 if (ta_number && (list->hashed[hash].ta_copied == ta_number)) 08940 item_p = ta_lookup_lol_item(ta_number, list, desc); 08941 else 08942 #endif 08943 item_p = lookup_lol_item(list, desc); 08944 if (item_p 08945 && (!item_p->max_age || (item_p->max_age > RSBAC_CURRENT_TIME) 08946 ) 08947 ) { /* exists -> TRUE */ 08948 result = TRUE; 08949 } else { 08950 result = FALSE; 08951 } 08952 rsbac_read_unlock(&list->lock, &lock_flags); 08953 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 08954 return result; 08955 }
long rsbac_ta_list_lol_get_all_data | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void ** | array_p | |||
) |
Definition at line 9635 of file gen_lists.c.
References rsbac_list_lol_hashed_t::count, rsbac_list_lol_info_t::data_size, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_hashed_t::head, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, rsbac_list_lol_item_t::max_age, rsbac_list_lol_item_t::next, rsbac_list_lol_reg_item_t::nr_hashes, NULL, RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDREQUEST, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTINITIALIZED, RSBAC_MAX_KMALLOC, rsbac_ta_list_exist(), rsbac_vmalloc, and rsbac_list_lol_reg_item_t::self.
Referenced by rsbac_list_lol_get_all_data().
09638 { 09639 struct rsbac_list_lol_reg_item_t *list; 09640 struct rsbac_list_lol_item_t *item_p; 09641 char *buffer; 09642 u_long lock_flags, rlock_flags; 09643 u_long offset = 0; 09644 long result = 0; 09645 u_int item_size; 09646 u_int item_offset; 09647 int i; 09648 u_long count = 0; 09649 09650 if (!handle) 09651 return -RSBAC_EINVALIDLIST; 09652 if (!array_p) 09653 return -RSBAC_EINVALIDPOINTER; 09654 if (!list_initialized) 09655 return -RSBAC_ENOTINITIALIZED; 09656 09657 list = (struct rsbac_list_lol_reg_item_t *) handle; 09658 if (list->self != list) 09659 return -RSBAC_EINVALIDLIST; 09660 *array_p = NULL; 09661 09662 #ifdef CONFIG_RSBAC_LIST_TRANS 09663 if (ta_number) { 09664 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 09665 return -RSBAC_EINVALIDTRANSACTION; 09666 } 09667 #endif 09668 09669 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 09670 /* 09671 rsbac_pr_debug(lists, "list %s.\n", list->name); 09672 */ 09673 rsbac_read_lock(&list->lock, &lock_flags); 09674 if (!list->info.data_size) { 09675 rsbac_read_unlock(&list->lock, &lock_flags); 09676 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 09677 return -RSBAC_EINVALIDREQUEST; 09678 } 09679 for (i=0; i<list->nr_hashes; i++) { 09680 #ifdef CONFIG_RSBAC_LIST_TRANS 09681 if (ta_number && (list->hashed[i].ta_copied == ta_number)) 09682 count += list->hashed[i].ta_count; 09683 else 09684 #endif 09685 count += list->hashed[i].count; 09686 } 09687 if(!count) { 09688 result = 0; 09689 goto out_unlock; 09690 } 09691 item_size = list->info.data_size; 09692 item_offset = list->info.desc_size; 09693 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 09694 if(count > RSBAC_MAX_KMALLOC / item_size) 09695 count = RSBAC_MAX_KMALLOC / item_size; 09696 #endif 09697 buffer = rsbac_vmalloc(item_size * count); 09698 if (!buffer) { 09699 result = -ENOMEM; 09700 goto out_unlock; 09701 } 09702 for (i=0; i<list->nr_hashes; i++) { 09703 #ifdef CONFIG_RSBAC_LIST_TRANS 09704 if (ta_number && (list->hashed[i].ta_copied == ta_number)) 09705 item_p = list->hashed[i].ta_head; 09706 else 09707 #endif 09708 item_p = list->hashed[i].head; 09709 while (item_p && (result < count)) { 09710 if (!item_p->max_age 09711 || (item_p->max_age > 09712 RSBAC_CURRENT_TIME) 09713 ) { 09714 memcpy(buffer + offset, 09715 ((char *) item_p) + 09716 sizeof(*item_p) + 09717 item_offset, item_size); 09718 offset += item_size; 09719 result++; 09720 } 09721 item_p = item_p->next; 09722 } 09723 } 09724 *array_p = buffer; 09725 09726 out_unlock: 09727 rsbac_read_unlock(&list->lock, &lock_flags); 09728 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 09729 return result; 09730 }
long rsbac_ta_list_lol_get_all_desc | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void ** | array_p | |||
) |
Definition at line 9344 of file gen_lists.c.
References rsbac_list_lol_hashed_t::count, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_hashed_t::head, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, rsbac_list_lol_item_t::max_age, rsbac_list_lol_reg_item_t::name, rsbac_list_lol_item_t::next, rsbac_list_lol_reg_item_t::nr_hashes, NULL, RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTINITIALIZED, RSBAC_MAX_KMALLOC, rsbac_pr_debug, rsbac_ta_list_exist(), rsbac_vmalloc, and rsbac_list_lol_reg_item_t::self.
Referenced by rsbac_acl_get_group_members(), rsbac_acl_list_all_dev(), rsbac_acl_list_all_major_dev(), rsbac_acl_list_all_user(), rsbac_list_lol_get_all_desc(), rsbac_um_get_gm_user_list(), and rsbac_um_get_user_list().
09347 { 09348 struct rsbac_list_lol_reg_item_t *list; 09349 struct rsbac_list_lol_item_t *item_p; 09350 char *buffer; 09351 u_long lock_flags, rlock_flags; 09352 u_long offset = 0; 09353 long result = 0; 09354 u_int item_size; 09355 int i; 09356 u_long count = 0; 09357 09358 if (!handle) 09359 return -RSBAC_EINVALIDLIST; 09360 if (!array_p) 09361 return -RSBAC_EINVALIDPOINTER; 09362 if (!list_initialized) 09363 return -RSBAC_ENOTINITIALIZED; 09364 09365 list = (struct rsbac_list_lol_reg_item_t *) handle; 09366 if (list->self != list) 09367 return -RSBAC_EINVALIDLIST; 09368 *array_p = NULL; 09369 09370 #ifdef CONFIG_RSBAC_LIST_TRANS 09371 if (ta_number) { 09372 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 09373 return -RSBAC_EINVALIDTRANSACTION; 09374 } 09375 #endif 09376 09377 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 09378 /* 09379 rsbac_pr_debug(lists, "list %s.\n", list->name); 09380 */ 09381 rsbac_read_lock(&list->lock, &lock_flags); 09382 for (i=0; i<list->nr_hashes; i++) { 09383 #ifdef CONFIG_RSBAC_LIST_TRANS 09384 if (ta_number && (list->hashed[i].ta_copied == ta_number)) 09385 count += list->hashed[i].ta_count; 09386 else 09387 #endif 09388 count += list->hashed[i].count; 09389 } 09390 if(!count) { 09391 result = 0; 09392 goto out_unlock; 09393 } 09394 item_size = list->info.desc_size; 09395 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 09396 if(count > RSBAC_MAX_KMALLOC / item_size) 09397 count = RSBAC_MAX_KMALLOC / item_size; 09398 #endif 09399 buffer = rsbac_vmalloc(item_size * count); 09400 if (!buffer) { 09401 result = -ENOMEM; 09402 rsbac_pr_debug(lists, "list %s: could not allocate buffer for %u items of size %u!\n", 09403 list->name, count, item_size); 09404 goto out_unlock; 09405 } 09406 for (i=0; i<list->nr_hashes; i++) { 09407 #ifdef CONFIG_RSBAC_LIST_TRANS 09408 if (ta_number && (list->hashed[i].ta_copied == ta_number)) 09409 item_p = list->hashed[i].ta_head; 09410 else 09411 #endif 09412 item_p = list->hashed[i].head; 09413 while (item_p && (result < count)) { 09414 if (!item_p->max_age 09415 || (item_p->max_age > 09416 RSBAC_CURRENT_TIME) 09417 ) { 09418 memcpy(buffer + offset, 09419 ((char *) item_p) + 09420 sizeof(*item_p), item_size); 09421 offset += item_size; 09422 result++; 09423 } 09424 item_p = item_p->next; 09425 } 09426 } 09427 *array_p = buffer; 09428 09429 out_unlock: 09430 rsbac_read_unlock(&list->lock, &lock_flags); 09431 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 09432 return result; 09433 }
long rsbac_ta_list_lol_get_all_items | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void ** | array_p | |||
) |
Definition at line 10012 of file gen_lists.c.
References rsbac_list_lol_hashed_t::count, rsbac_list_lol_info_t::data_size, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_hashed_t::head, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, rsbac_list_lol_item_t::max_age, rsbac_list_lol_item_t::next, rsbac_list_lol_reg_item_t::nr_hashes, NULL, RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTINITIALIZED, RSBAC_MAX_KMALLOC, rsbac_ta_list_exist(), rsbac_vmalloc, and rsbac_list_lol_reg_item_t::self.
Referenced by rsbac_list_lol_get_all_items().
10015 { 10016 struct rsbac_list_lol_reg_item_t *list; 10017 struct rsbac_list_lol_item_t *item_p; 10018 char *buffer; 10019 u_long lock_flags, rlock_flags; 10020 u_long offset = 0; 10021 long result = 0; 10022 u_int item_size; 10023 int i; 10024 u_long count = 0; 10025 10026 if (!handle) 10027 return -RSBAC_EINVALIDLIST; 10028 if (!array_p) 10029 return -RSBAC_EINVALIDPOINTER; 10030 if (!list_initialized) 10031 return -RSBAC_ENOTINITIALIZED; 10032 10033 list = (struct rsbac_list_lol_reg_item_t *) handle; 10034 if (list->self != list) 10035 return -RSBAC_EINVALIDLIST; 10036 *array_p = NULL; 10037 10038 #ifdef CONFIG_RSBAC_LIST_TRANS 10039 if (ta_number) { 10040 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 10041 return -RSBAC_EINVALIDTRANSACTION; 10042 } 10043 #endif 10044 10045 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 10046 /* 10047 rsbac_pr_debug(lists, "list %s.\n", list->name); 10048 */ 10049 rsbac_read_lock(&list->lock, &lock_flags); 10050 for (i=0; i<list->nr_hashes; i++) { 10051 #ifdef CONFIG_RSBAC_LIST_TRANS 10052 if (ta_number && (list->hashed[i].ta_copied == ta_number)) 10053 count += list->hashed[i].ta_count; 10054 else 10055 #endif 10056 count += list->hashed[i].count; 10057 } 10058 if(!count) { 10059 result = 0; 10060 goto out_unlock; 10061 } 10062 item_size = list->info.desc_size + list->info.data_size; 10063 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 10064 if(count > RSBAC_MAX_KMALLOC / item_size) 10065 count = RSBAC_MAX_KMALLOC / item_size; 10066 #endif 10067 buffer = rsbac_vmalloc(item_size * count); 10068 if (!buffer) { 10069 result = -ENOMEM; 10070 goto out_unlock; 10071 } 10072 for (i=0; i<list->nr_hashes; i++) { 10073 #ifdef CONFIG_RSBAC_LIST_TRANS 10074 if (ta_number && (list->hashed[i].ta_copied == ta_number)) 10075 item_p = list->hashed[i].ta_head; 10076 else 10077 #endif 10078 item_p = list->hashed[i].head; 10079 while (item_p && (result < count)) { 10080 if (!item_p->max_age 10081 || (item_p->max_age > 10082 RSBAC_CURRENT_TIME) 10083 ) { 10084 memcpy(buffer + offset, 10085 ((char *) item_p) + 10086 sizeof(*item_p), item_size); 10087 offset += item_size; 10088 result++; 10089 } 10090 item_p = item_p->next; 10091 } 10092 } 10093 *array_p = buffer; 10094 10095 out_unlock: 10096 rsbac_read_unlock(&list->lock, &lock_flags); 10097 rsbac_read_unlock(®_head.lock, &rlock_flags); 10098 return result; 10099 }
long rsbac_ta_list_lol_get_all_subdata | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void * | desc, | |||
void ** | array_p | |||
) |
Definition at line 9542 of file gen_lists.c.
References rsbac_list_lol_item_t::count, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_item_t::head, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, lookup_lol_item(), rsbac_list_item_t::max_age, rsbac_list_item_t::next, rsbac_list_lol_reg_item_t::nr_hashes, NULL, RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDREQUEST, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOMEM, RSBAC_ENOTINITIALIZED, RSBAC_MAX_KMALLOC, rsbac_ta_list_exist(), rsbac_vmalloc, rsbac_list_lol_reg_item_t::self, rsbac_list_lol_info_t::subdata_size, and rsbac_list_lol_info_t::subdesc_size.
Referenced by rsbac_list_lol_get_all_subdata(), and rsbac_um_good_pass().
09545 { 09546 struct rsbac_list_lol_reg_item_t *list; 09547 struct rsbac_list_lol_item_t *sublist; 09548 struct rsbac_list_item_t *item_p; 09549 char *buffer; 09550 u_long lock_flags, rlock_flags; 09551 u_long offset = 0; 09552 long result = 0; 09553 u_long count; 09554 u_int item_size; 09555 u_int item_offset; 09556 #ifdef CONFIG_RSBAC_LIST_TRANS 09557 u_int hash = 0; 09558 #endif 09559 09560 if (!handle) 09561 return -RSBAC_EINVALIDLIST; 09562 if (!array_p) 09563 return -RSBAC_EINVALIDPOINTER; 09564 if (!list_initialized) 09565 return -RSBAC_ENOTINITIALIZED; 09566 09567 list = (struct rsbac_list_lol_reg_item_t *) handle; 09568 if (list->self != list) 09569 return -RSBAC_EINVALIDLIST; 09570 *array_p = NULL; 09571 09572 #ifdef CONFIG_RSBAC_LIST_TRANS 09573 if (ta_number) { 09574 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 09575 return -RSBAC_EINVALIDTRANSACTION; 09576 if(list->hash_function) 09577 hash = list->hash_function(desc, list->nr_hashes); 09578 } 09579 #endif 09580 09581 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 09582 /* 09583 rsbac_pr_debug(lists, "list %s.\n", list->name); 09584 */ 09585 rsbac_read_lock(&list->lock, &lock_flags); 09586 if (!list->info.subdata_size) { 09587 rsbac_read_unlock(&list->lock, &lock_flags); 09588 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 09589 return -RSBAC_EINVALIDREQUEST; 09590 } 09591 #ifdef CONFIG_RSBAC_LIST_TRANS 09592 if (ta_number && (list->hashed[hash].ta_copied == ta_number)) 09593 sublist = ta_lookup_lol_item(ta_number, list, desc); 09594 else 09595 #endif 09596 sublist = lookup_lol_item(list, desc); 09597 if (sublist && sublist->count) { 09598 item_size = list->info.subdata_size; 09599 item_offset = list->info.subdesc_size; 09600 count = sublist->count; 09601 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 09602 if(count > RSBAC_MAX_KMALLOC / item_size) 09603 count = RSBAC_MAX_KMALLOC / item_size; 09604 #endif 09605 buffer = rsbac_vmalloc(item_size * count); 09606 if (buffer) { 09607 item_p = sublist->head; 09608 while (item_p && (result < count)) { 09609 if (!item_p->max_age 09610 || (item_p->max_age > 09611 RSBAC_CURRENT_TIME) 09612 ) { 09613 memcpy(buffer + offset, 09614 ((char *) item_p) + 09615 sizeof(*item_p) + 09616 item_offset, item_size); 09617 offset += item_size; 09618 result++; 09619 } 09620 item_p = item_p->next; 09621 } 09622 *array_p = buffer; 09623 } else { 09624 result = -RSBAC_ENOMEM; 09625 } 09626 } 09627 rsbac_read_unlock(&list->lock, &lock_flags); 09628 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 09629 return result; 09630 }
long rsbac_ta_list_lol_get_all_subdesc_ttl | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void * | desc, | |||
void ** | array_p, | |||
rsbac_time_t ** | ttl_array_p | |||
) |
Definition at line 9241 of file gen_lists.c.
References rsbac_list_lol_item_t::count, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_item_t::head, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, lookup_lol_item(), rsbac_list_item_t::max_age, rsbac_list_item_t::next, rsbac_list_lol_reg_item_t::nr_hashes, NULL, RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOMEM, RSBAC_ENOTINITIALIZED, RSBAC_MAX_KMALLOC, rsbac_ta_list_exist(), rsbac_vmalloc, rsbac_list_lol_reg_item_t::self, and rsbac_list_lol_info_t::subdesc_size.
Referenced by rsbac_acl_get_user_groups(), rsbac_auth_get_f_caplist(), rsbac_auth_get_p_caplist(), rsbac_list_lol_get_all_subdesc(), rsbac_list_lol_get_all_subdesc_ttl(), rsbac_mac_get_f_trulist(), rsbac_mac_get_p_trulist(), rsbac_rc_copy_role(), rsbac_rc_get_list(), and rsbac_um_get_gm_list().
09246 { 09247 struct rsbac_list_lol_reg_item_t *list; 09248 struct rsbac_list_lol_item_t *sublist; 09249 struct rsbac_list_item_t *item_p; 09250 char *buffer; 09251 rsbac_time_t *ttl_p = NULL; 09252 u_long lock_flags, rlock_flags; 09253 u_long offset = 0; 09254 long result = 0; 09255 u_long count; 09256 u_int item_size; 09257 #ifdef CONFIG_RSBAC_LIST_TRANS 09258 u_int hash = 0; 09259 #endif 09260 09261 if (!handle) 09262 return -RSBAC_EINVALIDLIST; 09263 if (!array_p) 09264 return -RSBAC_EINVALIDPOINTER; 09265 if (!list_initialized) 09266 return -RSBAC_ENOTINITIALIZED; 09267 09268 list = (struct rsbac_list_lol_reg_item_t *) handle; 09269 if (list->self != list) 09270 return -RSBAC_EINVALIDLIST; 09271 *array_p = NULL; 09272 09273 #ifdef CONFIG_RSBAC_LIST_TRANS 09274 if (ta_number) { 09275 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 09276 return -RSBAC_EINVALIDTRANSACTION; 09277 if(list->hash_function) 09278 hash = list->hash_function(desc, list->nr_hashes); 09279 } 09280 #endif 09281 09282 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 09283 /* 09284 rsbac_pr_debug(lists, "list %s.\n", list->name); 09285 */ 09286 rsbac_read_lock(&list->lock, &lock_flags); 09287 #ifdef CONFIG_RSBAC_LIST_TRANS 09288 if (ta_number && (list->hashed[hash].ta_copied == ta_number)) 09289 sublist = ta_lookup_lol_item(ta_number, list, desc); 09290 else 09291 #endif 09292 sublist = lookup_lol_item(list, desc); 09293 if (sublist && sublist->count) { 09294 item_size = list->info.subdesc_size; 09295 count = sublist->count; 09296 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 09297 if(count > RSBAC_MAX_KMALLOC / item_size) 09298 count = RSBAC_MAX_KMALLOC / item_size; 09299 #endif 09300 buffer = rsbac_vmalloc(item_size * count); 09301 if (buffer) { 09302 if (ttl_array_p) 09303 ttl_p = 09304 rsbac_vmalloc(sizeof(**ttl_array_p) * 09305 sublist->count); 09306 item_p = sublist->head; 09307 while (item_p && (result < count)) { 09308 if (!item_p->max_age 09309 || (item_p->max_age > 09310 RSBAC_CURRENT_TIME) 09311 ) { 09312 memcpy(buffer + offset, 09313 ((char *) item_p) + 09314 sizeof(*item_p), item_size); 09315 if (ttl_p) { 09316 if (item_p->max_age) 09317 ttl_p[result] = 09318 item_p-> 09319 max_age - 09320 RSBAC_CURRENT_TIME; 09321 else 09322 ttl_p[result] = 0; 09323 } 09324 offset += item_size; 09325 result++; 09326 } 09327 item_p = item_p->next; 09328 } 09329 *array_p = buffer; 09330 if (ttl_array_p) 09331 *ttl_array_p = ttl_p; 09332 } else { 09333 result = -RSBAC_ENOMEM; 09334 } 09335 } 09336 rsbac_read_unlock(&list->lock, &lock_flags); 09337 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 09338 return result; 09339 }
long rsbac_ta_list_lol_get_all_subitems_ttl | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void * | desc, | |||
void ** | array_p, | |||
rsbac_time_t ** | ttl_array_p | |||
) |
Definition at line 9908 of file gen_lists.c.
References rsbac_list_lol_item_t::count, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_item_t::head, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, lookup_lol_item(), rsbac_list_item_t::max_age, rsbac_list_item_t::next, rsbac_list_lol_reg_item_t::nr_hashes, NULL, RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOMEM, RSBAC_ENOTINITIALIZED, RSBAC_MAX_KMALLOC, rsbac_ta_list_exist(), rsbac_vmalloc, rsbac_list_lol_reg_item_t::self, rsbac_list_lol_info_t::subdata_size, and rsbac_list_lol_info_t::subdesc_size.
Referenced by rsbac_acl_get_tlist(), rsbac_list_lol_get_all_subitems(), rsbac_list_lol_get_all_subitems_ttl(), and rsbac_rc_copy_role().
09913 { 09914 struct rsbac_list_lol_reg_item_t *list; 09915 struct rsbac_list_lol_item_t *sublist; 09916 struct rsbac_list_item_t *item_p; 09917 char *buffer; 09918 rsbac_time_t *ttl_p = NULL; 09919 u_long lock_flags, rlock_flags; 09920 u_long offset = 0; 09921 long result = 0; 09922 u_long count; 09923 u_int item_size; 09924 #ifdef CONFIG_RSBAC_LIST_TRANS 09925 u_int hash = 0; 09926 #endif 09927 09928 if (!handle) 09929 return -RSBAC_EINVALIDLIST; 09930 if (!array_p) 09931 return -RSBAC_EINVALIDPOINTER; 09932 if (!list_initialized) 09933 return -RSBAC_ENOTINITIALIZED; 09934 09935 list = (struct rsbac_list_lol_reg_item_t *) handle; 09936 if (list->self != list) 09937 return -RSBAC_EINVALIDLIST; 09938 *array_p = NULL; 09939 09940 #ifdef CONFIG_RSBAC_LIST_TRANS 09941 if (ta_number) { 09942 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 09943 return -RSBAC_EINVALIDTRANSACTION; 09944 if(list->hash_function) 09945 hash = list->hash_function(desc, list->nr_hashes); 09946 } 09947 #endif 09948 09949 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 09950 /* 09951 rsbac_pr_debug(lists, "list %s.\n", list->name); 09952 */ 09953 rsbac_read_lock(&list->lock, &lock_flags); 09954 #ifdef CONFIG_RSBAC_LIST_TRANS 09955 if (ta_number && (list->hashed[hash].ta_copied == ta_number)) 09956 sublist = ta_lookup_lol_item(ta_number, list, desc); 09957 else 09958 #endif 09959 sublist = lookup_lol_item(list, desc); 09960 if (sublist && sublist->count) { 09961 count = sublist->count; 09962 item_size = 09963 list->info.subdesc_size + list->info.subdata_size; 09964 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 09965 if(count > RSBAC_MAX_KMALLOC / item_size) 09966 count = RSBAC_MAX_KMALLOC / item_size; 09967 #endif 09968 buffer = rsbac_vmalloc(item_size * count); 09969 if (buffer) { 09970 if (ttl_array_p) 09971 ttl_p = 09972 rsbac_vmalloc(sizeof(**ttl_array_p) * 09973 sublist->count); 09974 item_p = sublist->head; 09975 while (item_p && (result < count)) { 09976 if (!item_p->max_age 09977 || (item_p->max_age > 09978 RSBAC_CURRENT_TIME) 09979 ) { 09980 memcpy(buffer + offset, 09981 ((char *) item_p) + 09982 sizeof(*item_p), item_size); 09983 if (ttl_p) { 09984 if (item_p->max_age) 09985 ttl_p[result] = 09986 item_p-> 09987 max_age - 09988 RSBAC_CURRENT_TIME; 09989 else 09990 ttl_p[result] = 0; 09991 } 09992 offset += item_size; 09993 result++; 09994 } 09995 item_p = item_p->next; 09996 } 09997 *array_p = buffer; 09998 if (ttl_array_p) 09999 *ttl_array_p = ttl_p; 10000 } else { 10001 result = -RSBAC_ENOMEM; 10002 } 10003 } 10004 rsbac_read_unlock(&list->lock, &lock_flags); 10005 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 10006 return result; 10007 }
int rsbac_ta_list_lol_get_data_ttl | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
rsbac_time_t * | ttl_p, | |||
void * | desc, | |||
void * | data | |||
) |
Definition at line 8261 of file gen_lists.c.
References rsbac_list_lol_info_t::data_size, rsbac_list_lol_reg_item_t::def_data, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, lookup_lol_item(), rsbac_list_lol_item_t::max_age, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, RSBAC_EINVALIDREQUEST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_lol_reg_item_t::self.
Referenced by rsbac_acl_get_mask(), rsbac_acl_get_rights(), rsbac_acl_get_single_right(), rsbac_acl_remove_acl_entry(), rsbac_list_lol_get_data(), rsbac_list_lol_get_data_ttl(), rsbac_um_check_account(), rsbac_um_check_pass(), rsbac_um_get_user_entry(), rsbac_um_get_user_item(), rsbac_um_mod_user(), and rsbac_um_set_pass().
08265 { 08266 struct rsbac_list_lol_reg_item_t *list; 08267 struct rsbac_list_lol_item_t *item_p; 08268 u_long lock_flags, rlock_flags; 08269 int err = 0; 08270 #ifdef CONFIG_RSBAC_LIST_TRANS 08271 u_int hash = 0; 08272 #endif 08273 08274 if (!handle) 08275 return -RSBAC_EINVALIDLIST; 08276 if (!desc) 08277 return -RSBAC_EINVALIDVALUE; 08278 if (!list_initialized) 08279 return -RSBAC_ENOTINITIALIZED; 08280 08281 list = (struct rsbac_list_lol_reg_item_t *) handle; 08282 if (list->self != list) 08283 return -RSBAC_EINVALIDLIST; 08284 08285 #ifdef CONFIG_RSBAC_LIST_TRANS 08286 if (ta_number) { 08287 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 08288 return -RSBAC_EINVALIDTRANSACTION; 08289 if(list->hash_function) 08290 hash = list->hash_function(desc, list->nr_hashes); 08291 } 08292 #endif 08293 08294 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 08295 /* 08296 rsbac_pr_debug(lists, "getting data from list %s.\n", list->name); 08297 */ 08298 if (data && !list->info.data_size) { 08299 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 08300 return -RSBAC_EINVALIDREQUEST; 08301 } 08302 08303 rsbac_read_lock(&list->lock, &lock_flags); 08304 08305 #ifdef CONFIG_RSBAC_LIST_TRANS 08306 if (ta_number && (list->hashed[hash].ta_copied == ta_number)) 08307 item_p = ta_lookup_lol_item(ta_number, list, desc); 08308 else 08309 #endif 08310 item_p = lookup_lol_item(list, desc); 08311 if (item_p 08312 && (!item_p->max_age || (item_p->max_age > RSBAC_CURRENT_TIME) 08313 ) 08314 ) { /* exists -> copy data, if any */ 08315 if (ttl_p) { 08316 if (item_p->max_age) 08317 *ttl_p = 08318 item_p->max_age - RSBAC_CURRENT_TIME; 08319 else 08320 *ttl_p = 0; 08321 } 08322 if (data) { 08323 memcpy(data, 08324 ((char *) item_p) + sizeof(*item_p) + 08325 list->info.desc_size, list->info.data_size); 08326 } 08327 } else { 08328 if (!list->def_data) 08329 err = -RSBAC_ENOTFOUND; 08330 else { 08331 if (ttl_p) 08332 *ttl_p = 0; 08333 if (data) 08334 memcpy(data, 08335 list->def_data, 08336 list->info.data_size); 08337 } 08338 } 08339 rsbac_read_unlock(&list->lock, &lock_flags); 08340 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 08341 return err; 08342 }
int rsbac_ta_list_lol_get_desc | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void * | desc, | |||
void * | data, | |||
rsbac_list_data_compare_function_t | compare | |||
) |
Definition at line 8646 of file gen_lists.c.
References rsbac_list_lol_info_t::data_size, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, lookup_lol_item_data(), RSBAC_EINVALIDLIST, RSBAC_EINVALIDREQUEST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_lol_reg_item_t::self.
Referenced by rsbac_list_lol_get_desc(), and rsbac_um_get_uid().
08651 { 08652 struct rsbac_list_lol_reg_item_t *list; 08653 struct rsbac_list_lol_item_t *item_p; 08654 u_long lock_flags, rlock_flags; 08655 int err = 0; 08656 08657 if (!handle) 08658 return -RSBAC_EINVALIDLIST; 08659 if (!desc || !data) 08660 return -RSBAC_EINVALIDVALUE; 08661 if (!list_initialized) 08662 return -RSBAC_ENOTINITIALIZED; 08663 08664 list = (struct rsbac_list_lol_reg_item_t *) handle; 08665 if (list->self != list) 08666 return -RSBAC_EINVALIDLIST; 08667 08668 #ifdef CONFIG_RSBAC_LIST_TRANS 08669 if (ta_number) { 08670 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 08671 return -RSBAC_EINVALIDTRANSACTION; 08672 } 08673 #endif 08674 08675 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 08676 /* 08677 rsbac_pr_debug(lists, "getting desc from list %s.\n", list->name); 08678 */ 08679 if (!list->info.data_size) { 08680 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 08681 return -RSBAC_EINVALIDREQUEST; 08682 } 08683 08684 rsbac_read_lock(&list->lock, &lock_flags); 08685 08686 #ifdef CONFIG_RSBAC_LIST_TRANS 08687 item_p = ta_lookup_lol_item_data(ta_number, list, data, compare); 08688 #else 08689 item_p = lookup_lol_item_data(list, data, compare); 08690 #endif 08691 if (item_p) { /* exists -> copy desc */ 08692 memcpy(desc, 08693 ((char *) item_p) + sizeof(*item_p), 08694 list->info.desc_size); 08695 } else { 08696 err = -RSBAC_ENOTFOUND; 08697 } 08698 rsbac_read_unlock(&list->lock, &lock_flags); 08699 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 08700 return err; 08701 }
int rsbac_ta_list_lol_get_max_subdesc | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void * | desc, | |||
void * | subdesc | |||
) |
Definition at line 8082 of file gen_lists.c.
References rsbac_list_lol_reg_item_t::flags, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, lookup_lol_item(), rsbac_list_item_t::max_age, rsbac_list_lol_reg_item_t::nr_hashes, rsbac_list_item_t::prev, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, RSBAC_LIST_DEF_DATA, rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, rsbac_list_lol_info_t::subdesc_size, and rsbac_list_lol_item_t::tail.
Referenced by rsbac_um_set_pass().
08085 { 08086 struct rsbac_list_lol_reg_item_t *list; 08087 struct rsbac_list_lol_item_t *sublist; 08088 struct rsbac_list_item_t *item_p; 08089 u_long lock_flags, rlock_flags; 08090 int err = 0; 08091 #ifdef CONFIG_RSBAC_LIST_TRANS 08092 u_int hash = 0; 08093 #endif 08094 08095 if (!handle) 08096 return -RSBAC_EINVALIDLIST; 08097 if (!desc || !subdesc) 08098 return -RSBAC_EINVALIDVALUE; 08099 if (!list_initialized) 08100 return -RSBAC_ENOTINITIALIZED; 08101 08102 list = (struct rsbac_list_lol_reg_item_t *) handle; 08103 if (list->self != list) 08104 return -RSBAC_EINVALIDLIST; 08105 08106 #ifdef CONFIG_RSBAC_LIST_TRANS 08107 if (ta_number) { 08108 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 08109 return -RSBAC_EINVALIDTRANSACTION; 08110 if(list->hash_function) 08111 hash = list->hash_function(desc, list->nr_hashes); 08112 } 08113 #endif 08114 08115 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 08116 /* 08117 rsbac_pr_debug(lists, "getting data from list %s.\n", 08118 list->name); 08119 */ 08120 08121 rsbac_read_lock(&list->lock, &lock_flags); 08122 08123 #ifdef CONFIG_RSBAC_LIST_TRANS 08124 if (ta_number && (list->hashed[hash].ta_copied == ta_number)) 08125 sublist = ta_lookup_lol_item(ta_number, list, desc); 08126 else 08127 #endif 08128 sublist = lookup_lol_item(list, desc); 08129 if (sublist) { /* exists -> lookup subitem */ 08130 item_p = sublist->tail; 08131 while (item_p 08132 && item_p->max_age 08133 && (item_p->max_age > RSBAC_CURRENT_TIME) 08134 ) 08135 item_p = item_p->prev; 08136 if (item_p) 08137 memcpy(subdesc, (char *) item_p + sizeof(*item_p), 08138 list->info.subdesc_size); 08139 else { 08140 memset(subdesc, 0, list->info.subdesc_size); 08141 err = -RSBAC_ENOTFOUND; 08142 } 08143 } else { 08144 if (!(list->flags & RSBAC_LIST_DEF_DATA)) 08145 err = -RSBAC_ENOTFOUND; 08146 } 08147 rsbac_read_unlock(&list->lock, &lock_flags); 08148 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 08149 return err; 08150 }
int rsbac_ta_list_lol_get_next_desc | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void * | old_desc, | |||
void * | next_desc | |||
) |
Definition at line 8496 of file gen_lists.c.
References rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_hashed_t::head, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, lookup_lol_item(), rsbac_list_lol_item_t::max_age, rsbac_list_lol_item_t::next, rsbac_list_lol_reg_item_t::nr_hashes, NULL, RSBAC_EINVALIDLIST, RSBAC_EINVALIDPOINTER, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_lol_reg_item_t::self.
Referenced by rsbac_list_lol_get_next_desc(), and rsbac_um_get_next_user().
08499 { 08500 struct rsbac_list_lol_reg_item_t *list; 08501 struct rsbac_list_lol_item_t *item_p; 08502 u_long lock_flags, rlock_flags; 08503 u_int hash = 0; 08504 08505 if (!handle) 08506 return -RSBAC_EINVALIDLIST; 08507 if (!list_initialized) 08508 return -RSBAC_ENOTINITIALIZED; 08509 if (!next_desc) 08510 return -RSBAC_EINVALIDPOINTER; 08511 08512 list = (struct rsbac_list_lol_reg_item_t *) handle; 08513 if (list->self != list) 08514 return -RSBAC_EINVALIDLIST; 08515 08516 #ifdef CONFIG_RSBAC_LIST_TRANS 08517 if (ta_number) { 08518 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 08519 return -RSBAC_EINVALIDTRANSACTION; 08520 } 08521 #endif 08522 08523 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 08524 /* 08525 rsbac_pr_debug(lists, "list %s.\n", list->name); 08526 */ 08527 rsbac_read_lock(&list->lock, &lock_flags); 08528 if (old_desc) { 08529 if(list->hash_function) 08530 hash = list->hash_function(old_desc, list->nr_hashes); 08531 #ifdef CONFIG_RSBAC_LIST_TRANS 08532 if (ta_number && (list->hashed[hash].ta_copied == ta_number)) 08533 item_p = ta_lookup_lol_item(ta_number, list, old_desc); 08534 else 08535 #endif 08536 item_p = lookup_lol_item(list, old_desc); 08537 if(item_p) { 08538 item_p = item_p->next; 08539 while (item_p 08540 && item_p->max_age && (item_p->max_age > RSBAC_CURRENT_TIME) 08541 ) { 08542 item_p = item_p->next; 08543 } 08544 hash++; 08545 } else 08546 hash = 0; 08547 } else 08548 item_p = NULL; 08549 while (!item_p && (hash < list->nr_hashes)) { 08550 #ifdef CONFIG_RSBAC_LIST_TRANS 08551 if (ta_number && (list->hashed[hash].ta_copied == ta_number)) 08552 item_p = list->hashed[hash].ta_head; 08553 else 08554 #endif 08555 item_p = list->hashed[hash].head; 08556 while (item_p 08557 && item_p->max_age && (item_p->max_age > RSBAC_CURRENT_TIME) 08558 ) { 08559 item_p = item_p->next; 08560 } 08561 hash++; 08562 } 08563 if (item_p) { 08564 memcpy(next_desc, (char *) item_p + sizeof(*item_p), 08565 list->info.desc_size); 08566 } 08567 rsbac_read_unlock(&list->lock, &lock_flags); 08568 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 08569 if (item_p) 08570 return 0; 08571 else 08572 return -RSBAC_ENOTFOUND; 08573 }
int rsbac_ta_list_lol_get_subdata_ttl | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
rsbac_time_t * | ttl_p, | |||
void * | desc, | |||
void * | subdesc, | |||
void * | subdata | |||
) |
Definition at line 8155 of file gen_lists.c.
References rsbac_list_lol_reg_item_t::def_subdata, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, lookup_lol_item(), lookup_lol_subitem(), rsbac_list_item_t::max_age, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, RSBAC_EINVALIDREQUEST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, rsbac_list_lol_info_t::subdata_size, and rsbac_list_lol_info_t::subdesc_size.
Referenced by rsbac_acl_add_to_acl_entry(), rsbac_acl_get_group_members(), rsbac_acl_get_rights(), rsbac_acl_get_single_right(), rsbac_acl_remove_from_acl_entry(), rsbac_list_lol_get_subdata(), rsbac_list_lol_get_subdata_ttl(), rsbac_rc_copy_type(), and rsbac_rc_get_item().
08160 { 08161 struct rsbac_list_lol_reg_item_t *list; 08162 struct rsbac_list_lol_item_t *sublist; 08163 struct rsbac_list_item_t *item_p; 08164 u_long lock_flags, rlock_flags; 08165 int err = 0; 08166 #ifdef CONFIG_RSBAC_LIST_TRANS 08167 u_int hash = 0; 08168 #endif 08169 08170 if (!handle) 08171 return -RSBAC_EINVALIDLIST; 08172 if (!desc || !subdesc) 08173 return -RSBAC_EINVALIDVALUE; 08174 if (!list_initialized) 08175 return -RSBAC_ENOTINITIALIZED; 08176 08177 list = (struct rsbac_list_lol_reg_item_t *) handle; 08178 if (list->self != list) 08179 return -RSBAC_EINVALIDLIST; 08180 08181 #ifdef CONFIG_RSBAC_LIST_TRANS 08182 if (ta_number) { 08183 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 08184 return -RSBAC_EINVALIDTRANSACTION; 08185 if(list->hash_function) 08186 hash = list->hash_function(desc, list->nr_hashes); 08187 } 08188 #endif 08189 08190 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 08191 /* 08192 rsbac_pr_debug(lists, "getting data from list %s.\n", list->name); 08193 */ 08194 if (subdata && !list->info.subdata_size) { 08195 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 08196 return -RSBAC_EINVALIDREQUEST; 08197 } 08198 08199 rsbac_read_lock(&list->lock, &lock_flags); 08200 08201 #ifdef CONFIG_RSBAC_LIST_TRANS 08202 if (ta_number && (list->hashed[hash].ta_copied == ta_number)) 08203 sublist = ta_lookup_lol_item(ta_number, list, desc); 08204 else 08205 #endif 08206 sublist = lookup_lol_item(list, desc); 08207 if (sublist) { /* exists -> lookup subitem */ 08208 item_p = lookup_lol_subitem(list, sublist, subdesc); 08209 if (item_p 08210 && (!item_p->max_age 08211 || (item_p->max_age > RSBAC_CURRENT_TIME) 08212 ) 08213 ) { /* exists -> copy data, if any */ 08214 if (ttl_p) { 08215 if (item_p->max_age) 08216 *ttl_p = 08217 item_p->max_age - 08218 RSBAC_CURRENT_TIME; 08219 else 08220 *ttl_p = 0; 08221 } 08222 if (subdata) { 08223 memcpy(subdata, 08224 ((char *) item_p) + 08225 sizeof(*item_p) + 08226 list->info.subdesc_size, 08227 list->info.subdata_size); 08228 } 08229 } else { 08230 if (!list->def_subdata) 08231 err = -RSBAC_ENOTFOUND; 08232 else { 08233 if (ttl_p) 08234 *ttl_p = 0; 08235 if (subdata) 08236 memcpy(subdata, 08237 list->def_subdata, 08238 list->info.subdata_size); 08239 } 08240 } 08241 } else { 08242 if (!list->def_subdata) 08243 err = -RSBAC_ENOTFOUND; 08244 else { 08245 if (ttl_p) 08246 *ttl_p = 0; 08247 if (subdata) 08248 memcpy(subdata, 08249 list->def_subdata, 08250 list->info.subdata_size); 08251 } 08252 } 08253 rsbac_read_unlock(&list->lock, &lock_flags); 08254 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 08255 return err; 08256 }
int rsbac_ta_list_lol_remove | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void * | desc | |||
) |
Definition at line 7841 of file gen_lists.c.
References rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, lol_touch, lookup_lol_item(), rsbac_list_lol_reg_item_t::nr_hashes, remove_lol_item(), RSBAC_EBUSY, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, and TRUE.
Referenced by rsbac_acl_remove_acl(), rsbac_acl_remove_acl_entry(), rsbac_acl_remove_group_member(), rsbac_acl_remove_user(), rsbac_auth_clear_f_capset(), rsbac_auth_clear_p_capset(), rsbac_list_lol_remove(), rsbac_mac_clear_f_truset(), rsbac_mac_clear_p_truset(), rsbac_pm_exists(), rsbac_pm_remove_set(), rsbac_pm_remove_target(), rsbac_rc_copy_role(), rsbac_rc_set_item(), and rsbac_um_remove_user().
07843 { 07844 struct rsbac_list_lol_reg_item_t *list; 07845 u_long lock_flags, rlock_flags; 07846 u_int hash = 0; 07847 07848 if (!handle) 07849 return -RSBAC_EINVALIDLIST; 07850 if (!desc) 07851 return -RSBAC_EINVALIDVALUE; 07852 if (!list_initialized) 07853 return -RSBAC_ENOTINITIALIZED; 07854 07855 list = (struct rsbac_list_lol_reg_item_t *) handle; 07856 if (list->self != list) 07857 return -RSBAC_EINVALIDLIST; 07858 07859 #ifdef CONFIG_RSBAC_LIST_TRANS 07860 if (ta_number) { 07861 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 07862 return -RSBAC_EINVALIDTRANSACTION; 07863 } 07864 #endif 07865 07866 if(list->hash_function) 07867 hash = list->hash_function(desc, list->nr_hashes); 07868 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 07869 /* 07870 rsbac_pr_debug(lists, "removing from list of lists %s.\n", 07871 list->name); 07872 */ 07873 rsbac_write_lock(&list->lock, &lock_flags); 07874 #ifdef CONFIG_RSBAC_LIST_TRANS 07875 if (list->hashed[hash].ta_copied) { 07876 if (ta_number) { 07877 if (ta_lookup_lol_item 07878 (list->hashed[hash].ta_copied, list, desc)) { 07879 if (list->hashed[hash].ta_copied != ta_number) { 07880 rsbac_write_unlock(&list->lock, 07881 &lock_flags); 07882 rsbac_read_unlock(&lol_reg_head. 07883 lock, 07884 &rlock_flags); 07885 return -RSBAC_EBUSY; 07886 } else 07887 ta_remove_lol_item(ta_number, list, 07888 desc); 07889 } 07890 } else 07891 ta_remove_lol_item(list->hashed[hash].ta_copied, list, desc); 07892 } else { 07893 if (ta_number && lookup_lol_item(list, desc)) { 07894 ta_lol_copy(ta_number, list, hash); 07895 ta_remove_lol_item(ta_number, list, desc); 07896 } 07897 } 07898 if (!ta_number) 07899 #endif 07900 { 07901 if (lookup_lol_item(list, desc)) { /* exists -> remove */ 07902 remove_lol_item(list, desc); 07903 lol_touch(list); 07904 list->dirty = TRUE; 07905 } 07906 } 07907 rsbac_write_unlock(&list->lock, &lock_flags); 07908 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 07909 return 0; 07910 }
int rsbac_ta_list_lol_remove_all | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle | |||
) |
Definition at line 7916 of file gen_lists.c.
References rsbac_list_lol_reg_item_t::hashed, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EBUSY, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_lol_reg_item_t::self.
Referenced by rsbac_list_lol_remove_all().
07918 { 07919 struct rsbac_list_lol_reg_item_t *list; 07920 u_long lock_flags, rlock_flags; 07921 int i; 07922 07923 if (!handle) 07924 return -RSBAC_EINVALIDLIST; 07925 if (!list_initialized) 07926 return -RSBAC_ENOTINITIALIZED; 07927 07928 list = (struct rsbac_list_lol_reg_item_t *) handle; 07929 if (list->self != list) 07930 return -RSBAC_EINVALIDLIST; 07931 07932 #ifdef CONFIG_RSBAC_LIST_TRANS 07933 if (ta_number) { 07934 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 07935 return -RSBAC_EINVALIDTRANSACTION; 07936 } 07937 #endif 07938 07939 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 07940 /* 07941 rsbac_pr_debug(lists, "removing all items from list of lists %s.\n", 07942 list->name); 07943 */ 07944 rsbac_write_lock(&list->lock, &lock_flags); 07945 #ifdef CONFIG_RSBAC_LIST_TRANS 07946 for (i=0; i<list->nr_hashes; i++) { 07947 if (list->hashed[i].ta_copied) { 07948 if (ta_number) { 07949 if (list->hashed[i].ta_copied == ta_number) { 07950 ta_remove_all_lol_items(list, i); 07951 if (!list->hashed[i].head) { 07952 list->hashed[i].ta_copied = 0; 07953 } 07954 } else { 07955 rsbac_write_unlock(&list->lock, 07956 &lock_flags); 07957 rsbac_read_unlock(&lol_reg_head.lock, 07958 &rlock_flags); 07959 return -RSBAC_EBUSY; 07960 } 07961 } else 07962 ta_remove_all_lol_items(list, i); 07963 } else { 07964 if (ta_number) { 07965 if (list->hashed[i].head) { 07966 list->hashed[i].ta_head = NULL; 07967 list->hashed[i].ta_tail = NULL; 07968 list->hashed[i].ta_curr = NULL; 07969 list->hashed[i].ta_count = 0; 07970 list->hashed[i].ta_copied = ta_number; 07971 } 07972 } 07973 } 07974 } 07975 07976 if (!ta_number) 07977 #endif 07978 for (i=0; i<list->nr_hashes; i++) { 07979 if (list->hashed[i].head) { 07980 remove_all_lol_items(list, i); 07981 lol_touch(list); 07982 list->dirty = TRUE; 07983 } 07984 } 07985 rsbac_write_unlock(&list->lock, &lock_flags); 07986 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 07987 return 0; 07988 }
int rsbac_ta_list_lol_subadd_ttl | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
rsbac_time_t | ttl, | |||
void * | desc, | |||
void * | subdesc, | |||
void * | subdata | |||
) |
Definition at line 6902 of file gen_lists.c.
References add_lol_item(), add_lol_subitem(), rsbac_list_lol_reg_item_t::def_data, rsbac_list_lol_reg_item_t::def_subdata, rsbac_list_lol_reg_item_t::dirty, do_remove_lol_subitem(), rsbac_list_lol_reg_item_t::flags, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, lol_touch, lookup_lol_item(), lookup_lol_subitem(), rsbac_list_lol_item_t::max_age, rsbac_list_item_t::max_age, rsbac_list_lol_reg_item_t::nr_hashes, remove_lol_item(), RSBAC_EBUSY, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTARGET, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, RSBAC_LIST_DEF_DATA, RSBAC_LIST_MAX_AGE_LIMIT, RSBAC_LIST_TTL_KEEP, rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, rsbac_list_lol_info_t::subdata_size, and TRUE.
Referenced by rsbac_acl_add_group_member(), rsbac_acl_add_to_acl_entry(), rsbac_acl_remove_from_acl_entry(), rsbac_acl_set_acl_entry(), rsbac_auth_add_to_f_capset(), rsbac_auth_add_to_p_capset(), rsbac_list_lol_subadd(), rsbac_list_lol_subadd_ttl(), rsbac_mac_add_to_f_truset(), rsbac_mac_add_to_p_truset(), rsbac_pm_add_to_set(), rsbac_rc_copy_role(), rsbac_rc_copy_type(), rsbac_rc_set_item(), and rsbac_um_add_gm().
06906 { 06907 struct rsbac_list_lol_reg_item_t *list; 06908 struct rsbac_list_lol_item_t *sublist; 06909 struct rsbac_list_item_t *item_p; 06910 u_long lock_flags, rlock_flags; 06911 int err = 0; 06912 u_int hash = 0; 06913 06914 if (!handle) 06915 return -RSBAC_EINVALIDLIST; 06916 if (!desc || !subdesc) 06917 return -RSBAC_EINVALIDVALUE; 06918 if (!list_initialized) 06919 return -RSBAC_ENOTINITIALIZED; 06920 06921 list = (struct rsbac_list_lol_reg_item_t *) handle; 06922 if (!list || (list->self != list)) 06923 return -RSBAC_EINVALIDLIST; 06924 06925 #ifdef CONFIG_RSBAC_LIST_TRANS 06926 if (ta_number && !rsbac_ta_list_exist(0, ta_handle, &ta_number)) 06927 return -RSBAC_EINVALIDTRANSACTION; 06928 #endif 06929 06930 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 06931 if (list->info.subdata_size && !subdata) { 06932 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 06933 return -RSBAC_EINVALIDVALUE; 06934 } 06935 06936 /* 06937 rsbac_pr_debug(lists, "adding to list %s.\n", list->name); 06938 */ 06939 rsbac_write_lock(&list->lock, &lock_flags); 06940 06941 if(list->hash_function) 06942 hash = list->hash_function(desc, list->nr_hashes); 06943 #ifdef CONFIG_RSBAC_LIST_TRANS 06944 if (!ta_number) 06945 #endif 06946 { 06947 sublist = lookup_lol_item(list, desc); 06948 if (!sublist && (list->flags & RSBAC_LIST_DEF_DATA) 06949 ) 06950 sublist = 06951 add_lol_item(list, 0, desc, list->def_data); 06952 if (sublist) { 06953 if (sublist->max_age 06954 && (sublist->max_age <= RSBAC_CURRENT_TIME) 06955 ) { 06956 remove_lol_item(list, desc); 06957 err = -RSBAC_EINVALIDTARGET; 06958 } else { 06959 /* exists -> lookup subitem */ 06960 if (ttl && (ttl != RSBAC_LIST_TTL_KEEP)) { 06961 if (ttl > RSBAC_LIST_MAX_AGE_LIMIT) 06962 ttl = 06963 RSBAC_LIST_MAX_AGE_LIMIT; 06964 ttl += RSBAC_CURRENT_TIME; 06965 } 06966 item_p = 06967 lookup_lol_subitem(list, sublist, 06968 subdesc); 06969 if (item_p) { /* exists -> update data, if any */ 06970 if (ttl != RSBAC_LIST_TTL_KEEP) 06971 item_p->max_age = ttl; 06972 if (subdata 06973 && list->info.subdata_size) { 06974 if (list->def_subdata 06975 && !item_p->max_age 06976 && !memcmp(list-> 06977 def_subdata, 06978 subdata, 06979 list->info. 06980 subdata_size) 06981 ) 06982 do_remove_lol_subitem 06983 (sublist, 06984 item_p); 06985 else 06986 memcpy(((char *) 06987 item_p) + 06988 sizeof 06989 (*item_p) + 06990 list->info. 06991 subdesc_size, 06992 subdata, 06993 list->info. 06994 subdata_size); 06995 } 06996 } else { 06997 if (ttl == RSBAC_LIST_TTL_KEEP) 06998 ttl = 0; 06999 if (!list->def_subdata 07000 || memcmp(list->def_subdata, 07001 subdata, 07002 list->info. 07003 subdata_size) 07004 ) 07005 add_lol_subitem(list, 07006 sublist, 07007 ttl, 07008 subdesc, 07009 subdata); 07010 } 07011 lol_touch(list); 07012 list->dirty = TRUE; 07013 } 07014 } else { 07015 err = -RSBAC_EINVALIDTARGET; 07016 goto out_unlock; 07017 } 07018 } 07019 #ifdef CONFIG_RSBAC_LIST_TRANS 07020 if (list->hashed[hash].ta_copied || ta_number) { 07021 if (!list->hashed[hash].ta_copied) { 07022 if ((err = ta_lol_copy(ta_number, list, hash))) 07023 goto out_unlock; 07024 } else if (ta_number) { 07025 if (list->hashed[hash].ta_copied != ta_number) { 07026 err = -RSBAC_EBUSY; 07027 goto out_unlock; 07028 } 07029 } else 07030 ta_number = list->hashed[hash].ta_copied; 07031 sublist = ta_lookup_lol_item(ta_number, list, desc); 07032 if (!sublist && (list->flags & RSBAC_LIST_DEF_DATA) 07033 ) 07034 sublist = 07035 ta_add_lol_item(ta_number, list, 0, desc, 07036 list->def_data); 07037 if (sublist) { 07038 if (sublist->max_age 07039 && (sublist->max_age <= RSBAC_CURRENT_TIME) 07040 ) { 07041 ta_remove_lol_item(ta_number, list, desc); 07042 err = -RSBAC_EINVALIDTARGET; 07043 } else { 07044 /* exists -> lookup subitem */ 07045 if (ttl && (ttl != RSBAC_LIST_TTL_KEEP)) { 07046 if (ttl > RSBAC_LIST_MAX_AGE_LIMIT) 07047 ttl = 07048 RSBAC_LIST_MAX_AGE_LIMIT; 07049 ttl += RSBAC_CURRENT_TIME; 07050 } 07051 item_p = 07052 lookup_lol_subitem(list, sublist, 07053 subdesc); 07054 if (item_p) { /* exists -> update data, if any */ 07055 if (ttl != RSBAC_LIST_TTL_KEEP) 07056 item_p->max_age = ttl; 07057 if (subdata 07058 && list->info.subdata_size) { 07059 if (list->def_subdata 07060 && !item_p->max_age 07061 && !memcmp(list-> 07062 def_subdata, 07063 subdata, 07064 list->info. 07065 subdata_size) 07066 ) 07067 do_remove_lol_subitem 07068 (sublist, 07069 item_p); 07070 else 07071 memcpy(((char *) 07072 item_p) + 07073 sizeof 07074 (*item_p) + 07075 list->info. 07076 subdesc_size, 07077 subdata, 07078 list->info. 07079 subdata_size); 07080 } 07081 } else { 07082 if (ttl == RSBAC_LIST_TTL_KEEP) 07083 ttl = 0; 07084 if (!list->def_subdata 07085 || memcmp(list->def_subdata, 07086 subdata, 07087 list->info. 07088 subdata_size) 07089 ) 07090 add_lol_subitem(list, 07091 sublist, 07092 ttl, 07093 subdesc, 07094 subdata); 07095 } 07096 } 07097 } else { 07098 err = -RSBAC_EINVALIDTARGET; 07099 } 07100 } 07101 #endif 07102 07103 out_unlock: 07104 rsbac_write_unlock(&list->lock, &lock_flags); 07105 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 07106 return err; 07107 }
long rsbac_ta_list_lol_subcount | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void * | desc | |||
) |
Definition at line 8962 of file gen_lists.c.
References rsbac_list_lol_item_t::count, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, lookup_lol_item(), rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTFOUND, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_lol_reg_item_t::self.
Referenced by rsbac_acl_remove_acl_entry(), rsbac_acl_remove_group_member(), rsbac_list_lol_subcount(), rsbac_rc_get_list(), and rsbac_um_get_gm_list().
08964 { 08965 struct rsbac_list_lol_reg_item_t *list; 08966 struct rsbac_list_lol_item_t *sublist; 08967 u_long lock_flags, rlock_flags; 08968 long result; 08969 #ifdef CONFIG_RSBAC_LIST_TRANS 08970 u_int hash = 0; 08971 #endif 08972 08973 if (!handle) 08974 return -RSBAC_EINVALIDLIST; 08975 if (!list_initialized) 08976 return -RSBAC_ENOTINITIALIZED; 08977 08978 list = (struct rsbac_list_lol_reg_item_t *) handle; 08979 if (list->self != list) 08980 return -RSBAC_EINVALIDLIST; 08981 08982 #ifdef CONFIG_RSBAC_LIST_TRANS 08983 if (ta_number) { 08984 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 08985 return -RSBAC_EINVALIDTRANSACTION; 08986 if(list->hash_function) 08987 hash = list->hash_function(desc, list->nr_hashes); 08988 } 08989 #endif 08990 08991 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 08992 /* 08993 rsbac_pr_debug(lists, "list %s.\n", list->name); 08994 */ 08995 rsbac_read_lock(&list->lock, &lock_flags); 08996 08997 #ifdef CONFIG_RSBAC_LIST_TRANS 08998 if (ta_number && (list->hashed[hash].ta_copied == ta_number)) 08999 sublist = ta_lookup_lol_item(ta_number, list, desc); 09000 else 09001 #endif 09002 sublist = lookup_lol_item(list, desc); 09003 if (sublist) { 09004 result = sublist->count; 09005 } else { 09006 result = -RSBAC_ENOTFOUND; 09007 } 09008 rsbac_read_unlock(&list->lock, &lock_flags); 09009 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 09010 return result; 09011 }
int rsbac_ta_list_lol_subexist | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void * | desc, | |||
void * | subdesc | |||
) |
Definition at line 8765 of file gen_lists.c.
References FALSE, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, lookup_lol_item(), lookup_lol_subitem(), rsbac_list_item_t::max_age, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, and TRUE.
Referenced by rsbac_acl_group_member(), rsbac_list_lol_subexist(), rsbac_pm_set_member(), and rsbac_um_get_gm_user_list().
08768 { 08769 struct rsbac_list_lol_reg_item_t *list; 08770 struct rsbac_list_lol_item_t *sublist; 08771 u_long lock_flags, rlock_flags; 08772 struct rsbac_list_item_t *item_p; 08773 int result; 08774 #ifdef CONFIG_RSBAC_LIST_TRANS 08775 u_int hash = 0; 08776 #endif 08777 08778 if (!handle || !desc || !subdesc) 08779 return FALSE; 08780 if (!list_initialized) 08781 return FALSE; 08782 08783 list = (struct rsbac_list_lol_reg_item_t *) handle; 08784 if (list->self != list) 08785 return -RSBAC_EINVALIDLIST; 08786 08787 #ifdef CONFIG_RSBAC_LIST_TRANS 08788 if (ta_number) { 08789 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 08790 return -RSBAC_EINVALIDTRANSACTION; 08791 if(list->hash_function) 08792 hash = list->hash_function(desc, list->nr_hashes); 08793 } 08794 #endif 08795 08796 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 08797 /* 08798 rsbac_pr_debug(lists, "testing on list %s.\n", list->name); 08799 */ 08800 rsbac_read_lock(&list->lock, &lock_flags); 08801 08802 #ifdef CONFIG_RSBAC_LIST_TRANS 08803 if (ta_number && (list->hashed[hash].ta_copied == ta_number)) 08804 sublist = ta_lookup_lol_item(ta_number, list, desc); 08805 else 08806 #endif 08807 sublist = lookup_lol_item(list, desc); 08808 if (sublist) { /* exists -> lookup subitem */ 08809 item_p = lookup_lol_subitem(list, sublist, subdesc); 08810 if (item_p 08811 && (!item_p->max_age 08812 || (item_p->max_age > RSBAC_CURRENT_TIME) 08813 ) 08814 ) { /* exists -> TRUE */ 08815 result = TRUE; 08816 } else { 08817 result = FALSE; 08818 } 08819 } else { 08820 result = FALSE; 08821 } 08822 rsbac_read_unlock(&list->lock, &lock_flags); 08823 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 08824 return result; 08825 }
int rsbac_ta_list_lol_subexist_compare | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void * | desc, | |||
void * | subdesc, | |||
rsbac_list_compare_function_t | compare | |||
) |
Definition at line 8830 of file gen_lists.c.
References FALSE, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, lookup_lol_item(), lookup_lol_subitem_user_compare(), rsbac_list_item_t::max_age, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, rsbac_list_lol_subexist(), rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, and TRUE.
Referenced by rsbac_list_lol_subexist_compare().
08836 { 08837 struct rsbac_list_lol_reg_item_t *list; 08838 struct rsbac_list_lol_item_t *sublist; 08839 u_long lock_flags, rlock_flags; 08840 struct rsbac_list_item_t *item_p; 08841 int result; 08842 #ifdef CONFIG_RSBAC_LIST_TRANS 08843 u_int hash = 0; 08844 #endif 08845 08846 if (!handle || !desc || !subdesc) 08847 return FALSE; 08848 if (!list_initialized) 08849 return FALSE; 08850 /* Use standard function, if compare is not provided. */ 08851 if (!compare) 08852 return rsbac_list_lol_subexist(handle, desc, subdesc); 08853 08854 list = (struct rsbac_list_lol_reg_item_t *) handle; 08855 if (list->self != list) 08856 return -RSBAC_EINVALIDLIST; 08857 08858 #ifdef CONFIG_RSBAC_LIST_TRANS 08859 if (ta_number) { 08860 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 08861 return -RSBAC_EINVALIDTRANSACTION; 08862 if(list->hash_function) 08863 hash = list->hash_function(desc, list->nr_hashes); 08864 } 08865 #endif 08866 08867 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 08868 /* 08869 rsbac_pr_debug(lists, "testing on list %s.\n", list->name); 08870 */ 08871 rsbac_read_lock(&list->lock, &lock_flags); 08872 08873 #ifdef CONFIG_RSBAC_LIST_TRANS 08874 if (ta_number && (list->hashed[hash].ta_copied == ta_number)) 08875 sublist = ta_lookup_lol_item(ta_number, list, desc); 08876 else 08877 #endif 08878 sublist = lookup_lol_item(list, desc); 08879 if (sublist) { /* exists -> lookup subitem */ 08880 item_p = 08881 lookup_lol_subitem_user_compare(list, sublist, subdesc, 08882 compare); 08883 if (item_p 08884 && (!item_p->max_age 08885 || (item_p->max_age > RSBAC_CURRENT_TIME) 08886 ) 08887 ) { /* exists -> TRUE */ 08888 result = TRUE; 08889 } else { 08890 result = FALSE; 08891 } 08892 } else { 08893 result = FALSE; 08894 } 08895 rsbac_read_unlock(&list->lock, &lock_flags); 08896 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 08897 return result; 08898 }
int rsbac_ta_list_lol_subremove | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void * | desc, | |||
void * | subdesc | |||
) |
Definition at line 7529 of file gen_lists.c.
References rsbac_list_lol_item_t::count, rsbac_list_lol_info_t::data_size, rsbac_list_lol_reg_item_t::def_data, rsbac_list_lol_info_t::desc_size, do_remove_lol_item(), rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, lol_touch, lookup_lol_item(), lookup_lol_subitem(), rsbac_list_lol_item_t::max_age, rsbac_list_lol_reg_item_t::nr_hashes, remove_lol_subitem(), RSBAC_EBUSY, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, RSBAC_LIST_DEF_DATA, rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, and TRUE.
Referenced by rsbac_acl_remove_acl_entry(), rsbac_acl_remove_group_member(), rsbac_auth_remove_from_f_capset(), rsbac_auth_remove_from_p_capset(), rsbac_list_lol_subremove(), rsbac_mac_remove_from_f_truset(), rsbac_mac_remove_from_p_truset(), rsbac_pm_remove_from_set(), rsbac_rc_set_item(), and rsbac_um_remove_gm().
07532 { 07533 struct rsbac_list_lol_reg_item_t *list; 07534 struct rsbac_list_lol_item_t *sublist; 07535 u_long lock_flags, rlock_flags; 07536 u_int hash = 0; 07537 07538 if (!handle) 07539 return -RSBAC_EINVALIDLIST; 07540 if (!desc || !subdesc) 07541 return -RSBAC_EINVALIDVALUE; 07542 if (!list_initialized) 07543 return -RSBAC_ENOTINITIALIZED; 07544 07545 list = (struct rsbac_list_lol_reg_item_t *) handle; 07546 if (list->self != list) 07547 return -RSBAC_EINVALIDLIST; 07548 07549 #ifdef CONFIG_RSBAC_LIST_TRANS 07550 if (ta_number) { 07551 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 07552 return -RSBAC_EINVALIDTRANSACTION; 07553 } 07554 #endif 07555 07556 if(list->hash_function) 07557 hash = list->hash_function(desc, list->nr_hashes); 07558 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 07559 /* 07560 rsbac_pr_debug(lists, "removing from list of lists %s, device %02u:%02u.\n", 07561 list->name, RSBAC_MAJOR(list->device), 07562 RSBAC_MINOR(list->device)); 07563 */ 07564 rsbac_write_lock(&list->lock, &lock_flags); 07565 #ifdef CONFIG_RSBAC_LIST_TRANS 07566 if (list->hashed[hash].ta_copied) { 07567 sublist = ta_lookup_lol_item(list->hashed[hash].ta_copied, list, desc); 07568 if (sublist) { 07569 if (sublist->max_age 07570 && (sublist->max_age <= RSBAC_CURRENT_TIME) 07571 ) { 07572 ta_do_remove_lol_item(list, sublist, hash); 07573 } else { 07574 if (ta_number 07575 && (list->hashed[hash].ta_copied != ta_number)) { 07576 rsbac_write_unlock(&list->lock, 07577 &lock_flags); 07578 rsbac_read_unlock(&lol_reg_head. 07579 lock, 07580 &rlock_flags); 07581 return -RSBAC_EBUSY; 07582 } 07583 if (lookup_lol_subitem 07584 (list, sublist, subdesc)) 07585 remove_lol_subitem(list, sublist, 07586 subdesc); 07587 if (!sublist->count 07588 && 07589 ((list->def_data 07590 && !memcmp(((char *) sublist) + 07591 sizeof(*sublist) + 07592 list->info.desc_size, 07593 list->def_data, 07594 list->info.data_size) 07595 ) 07596 || (!list->info.data_size 07597 && (list-> 07598 flags & RSBAC_LIST_DEF_DATA) 07599 ) 07600 ) 07601 ) { 07602 ta_do_remove_lol_item(list, 07603 sublist, 07604 hash); 07605 } 07606 } 07607 } 07608 } else { 07609 if (ta_number && lookup_lol_item(list, desc)) { 07610 ta_lol_copy(ta_number, list, hash); 07611 ta_remove_lol_item(ta_number, list, desc); 07612 } 07613 } 07614 if (!ta_number) 07615 #endif 07616 { 07617 sublist = lookup_lol_item(list, desc); 07618 if (sublist) { 07619 if (sublist->max_age 07620 && (sublist->max_age <= RSBAC_CURRENT_TIME) 07621 ) { 07622 do_remove_lol_item(list, sublist, hash); 07623 lol_touch(list); 07624 list->dirty = TRUE; 07625 } else { 07626 if (lookup_lol_subitem(list, sublist, subdesc)) { /* exists -> remove and set dirty */ 07627 remove_lol_subitem(list, sublist, 07628 subdesc); 07629 lol_touch(list); 07630 list->dirty = TRUE; 07631 } 07632 if (!sublist->count 07633 && ((list->def_data 07634 && !memcmp(((char *) sublist) + 07635 sizeof(*sublist) + 07636 list->info.desc_size, 07637 list->def_data, 07638 list->info.data_size) 07639 ) 07640 || (!list->info.data_size 07641 && (list-> 07642 flags & 07643 RSBAC_LIST_DEF_DATA) 07644 ) 07645 ) 07646 ) { 07647 do_remove_lol_item(list, sublist, hash); 07648 lol_touch(list); 07649 list->dirty = TRUE; 07650 } 07651 } 07652 } 07653 } 07654 rsbac_write_unlock(&list->lock, &lock_flags); 07655 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 07656 return 0; 07657 }
int rsbac_ta_list_lol_subremove_all | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void * | desc | |||
) |
Definition at line 7744 of file gen_lists.c.
References rsbac_list_lol_info_t::data_size, rsbac_list_lol_reg_item_t::def_data, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::dirty, rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_item_t::head, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, lol_touch, lookup_lol_item(), rsbac_list_lol_item_t::max_age, rsbac_list_lol_reg_item_t::nr_hashes, remove_all_lol_subitems(), RSBAC_EBUSY, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTINITIALIZED, RSBAC_LIST_DEF_DATA, rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, and TRUE.
Referenced by rsbac_list_lol_subremove_all(), and rsbac_pm_clear_set().
07746 { 07747 struct rsbac_list_lol_reg_item_t *list; 07748 struct rsbac_list_lol_item_t *sublist; 07749 u_long lock_flags, rlock_flags; 07750 u_int hash = 0; 07751 07752 if (!handle) 07753 return -RSBAC_EINVALIDLIST; 07754 if (!list_initialized) 07755 return -RSBAC_ENOTINITIALIZED; 07756 07757 list = (struct rsbac_list_lol_reg_item_t *) handle; 07758 if (list->self != list) 07759 return -RSBAC_EINVALIDLIST; 07760 07761 #ifdef CONFIG_RSBAC_LIST_TRANS 07762 if (ta_number) { 07763 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 07764 return -RSBAC_EINVALIDTRANSACTION; 07765 } 07766 #endif 07767 07768 if(list->hash_function) 07769 hash = list->hash_function(desc, list->nr_hashes); 07770 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 07771 /* 07772 rsbac_pr_debug(lists, "removing all subitems from list of lists %s.\n", 07773 list->name); 07774 */ 07775 rsbac_write_lock(&list->lock, &lock_flags); 07776 #ifdef CONFIG_RSBAC_LIST_TRANS 07777 if (list->hashed[hash].ta_copied) { 07778 sublist = ta_lookup_lol_item(list->hashed[hash].ta_copied, list, desc); 07779 if (sublist) { 07780 if (sublist->max_age 07781 && (sublist->max_age <= RSBAC_CURRENT_TIME) 07782 ) { 07783 ta_do_remove_lol_item(list, sublist, hash); 07784 } else { 07785 if (ta_number 07786 && (list->hashed[hash].ta_copied != ta_number)) { 07787 rsbac_write_unlock(&list->lock, 07788 &lock_flags); 07789 rsbac_read_unlock(&lol_reg_head. 07790 lock, 07791 &rlock_flags); 07792 return -RSBAC_EBUSY; 07793 } 07794 remove_all_lol_subitems(sublist); 07795 if ((list->def_data 07796 && !memcmp(((char *) sublist) + 07797 sizeof(*sublist) + 07798 list->info.desc_size, 07799 list->def_data, 07800 list->info.data_size) 07801 ) 07802 || (!list->info.data_size 07803 && (list-> 07804 flags & RSBAC_LIST_DEF_DATA) 07805 ) 07806 07807 ) { 07808 ta_do_remove_lol_item(list, 07809 sublist, 07810 hash); 07811 } 07812 } 07813 } 07814 } else { 07815 if (ta_number && lookup_lol_item(list, desc)) { 07816 ta_lol_copy(ta_number, list, hash); 07817 sublist = 07818 ta_lookup_lol_item(ta_number, list, desc); 07819 if (sublist) 07820 remove_all_lol_subitems(sublist); 07821 } 07822 } 07823 if (!ta_number) 07824 #endif 07825 { 07826 sublist = lookup_lol_item(list, desc); 07827 if (sublist && sublist->head) { 07828 remove_all_lol_subitems(sublist); 07829 lol_touch(list); 07830 list->dirty = TRUE; 07831 } 07832 } 07833 rsbac_write_unlock(&list->lock, &lock_flags); 07834 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 07835 return 0; 07836 }
int rsbac_ta_list_lol_subremove_count | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void * | desc, | |||
u_long | count | |||
) |
Definition at line 7392 of file gen_lists.c.
References rsbac_list_lol_item_t::count, rsbac_list_lol_info_t::data_size, rsbac_list_lol_reg_item_t::def_data, rsbac_list_lol_info_t::desc_size, rsbac_list_lol_reg_item_t::dirty, do_remove_lol_item(), do_remove_lol_subitem(), rsbac_list_lol_reg_item_t::hash_function, rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_item_t::head, rsbac_list_lol_reg_item_t::info, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, lol_touch, lookup_lol_item(), rsbac_list_lol_item_t::max_age, rsbac_list_lol_reg_item_t::nr_hashes, RSBAC_EBUSY, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, RSBAC_LIST_DEF_DATA, rsbac_ta_list_exist(), rsbac_list_lol_reg_item_t::self, and TRUE.
Referenced by rsbac_um_set_pass().
07395 { 07396 struct rsbac_list_lol_reg_item_t *list; 07397 struct rsbac_list_lol_item_t *sublist; 07398 u_long lock_flags, rlock_flags; 07399 u_int hash = 0; 07400 07401 if (!count) 07402 return 0; 07403 if (!handle) 07404 return -RSBAC_EINVALIDLIST; 07405 if (!desc) 07406 return -RSBAC_EINVALIDVALUE; 07407 if (!list_initialized) 07408 return -RSBAC_ENOTINITIALIZED; 07409 07410 list = (struct rsbac_list_lol_reg_item_t *) handle; 07411 if (list->self != list) 07412 return -RSBAC_EINVALIDLIST; 07413 07414 #ifdef CONFIG_RSBAC_LIST_TRANS 07415 if (ta_number) { 07416 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 07417 return -RSBAC_EINVALIDTRANSACTION; 07418 } 07419 #endif 07420 07421 if(list->hash_function) 07422 hash = list->hash_function(desc, list->nr_hashes); 07423 07424 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 07425 /* 07426 rsbac_pr_debug(lists, "removing from list of lists %s, device %02u:%02u.\n", 07427 list->name, RSBAC_MAJOR(list->device), 07428 RSBAC_MINOR(list->device)); 07429 */ 07430 rsbac_write_lock(&list->lock, &lock_flags); 07431 #ifdef CONFIG_RSBAC_LIST_TRANS 07432 if (list->hashed[hash].ta_copied) { 07433 sublist = ta_lookup_lol_item(list->hashed[hash].ta_copied, list, desc); 07434 if (sublist) { 07435 if (sublist->max_age 07436 && (sublist->max_age <= RSBAC_CURRENT_TIME) 07437 ) { 07438 ta_do_remove_lol_item(list, sublist, hash); 07439 } else { 07440 if (ta_number 07441 && (list->hashed[hash].ta_copied != ta_number)) { 07442 rsbac_write_unlock(&list->lock, 07443 &lock_flags); 07444 rsbac_read_unlock(&lol_reg_head. 07445 lock, 07446 &rlock_flags); 07447 return -RSBAC_EBUSY; 07448 } 07449 while (sublist->head && (count > 0)) { 07450 do_remove_lol_subitem(sublist, 07451 sublist->head); 07452 count--; 07453 } 07454 if (!sublist->count 07455 && ((list->def_data 07456 && !memcmp(((char *) sublist) + 07457 sizeof(*sublist) + 07458 list->info.desc_size, 07459 list->def_data, 07460 list->info.data_size) 07461 ) 07462 || (!list->info.data_size 07463 && (list-> 07464 flags & 07465 RSBAC_LIST_DEF_DATA) 07466 ) 07467 ) 07468 ) { 07469 ta_do_remove_lol_item(list, 07470 sublist, 07471 hash); 07472 } 07473 } 07474 } 07475 } else { 07476 if (ta_number && lookup_lol_item(list, desc)) { 07477 ta_lol_copy(ta_number, list, hash); 07478 ta_remove_lol_item(ta_number, list, desc); 07479 } 07480 } 07481 if (!ta_number) 07482 #endif 07483 { 07484 sublist = lookup_lol_item(list, desc); 07485 if (sublist) { 07486 if (sublist->max_age 07487 && (sublist->max_age <= RSBAC_CURRENT_TIME) 07488 ) { 07489 do_remove_lol_item(list, sublist, hash); 07490 lol_touch(list); 07491 list->dirty = TRUE; 07492 } else { 07493 while (sublist->head && (count > 0)) { 07494 do_remove_lol_subitem(sublist, 07495 sublist->head); 07496 count--; 07497 } 07498 lol_touch(list); 07499 list->dirty = TRUE; 07500 if (!sublist->count 07501 && ((list->def_data 07502 && !memcmp(((char *) sublist) + 07503 sizeof(*sublist) + 07504 list->info.desc_size, 07505 list->def_data, 07506 list->info.data_size) 07507 ) 07508 || (!list->info.data_size 07509 && (list-> 07510 flags & 07511 RSBAC_LIST_DEF_DATA) 07512 ) 07513 ) 07514 ) { 07515 do_remove_lol_item(list, sublist, hash); 07516 } 07517 } 07518 } 07519 } 07520 rsbac_write_unlock(&list->lock, &lock_flags); 07521 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 07522 return 0; 07523 }
int rsbac_ta_list_lol_subremove_from_all | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void * | subdesc | |||
) |
Definition at line 7663 of file gen_lists.c.
References rsbac_list_lol_reg_item_t::hashed, rsbac_list_lol_hashed_t::head, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_lol_reg_item_t::lock, lol_reg_head, rsbac_list_lol_item_t::next, rsbac_list_lol_reg_item_t::nr_hashes, remove_lol_subitem(), RSBAC_EBUSY, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_lol_reg_item_t::self.
Referenced by rsbac_acl_remove_group(), rsbac_acl_remove_subject(), rsbac_acl_remove_user(), rsbac_list_lol_subremove_from_all(), rsbac_rc_copy_type(), rsbac_rc_set_item(), and rsbac_um_remove_group().
07666 { 07667 struct rsbac_list_lol_reg_item_t *list; 07668 struct rsbac_list_lol_item_t *sublist; 07669 u_long lock_flags, rlock_flags; 07670 int i; 07671 07672 if (!handle) 07673 return -RSBAC_EINVALIDLIST; 07674 if (!subdesc) 07675 return -RSBAC_EINVALIDVALUE; 07676 if (!list_initialized) 07677 return -RSBAC_ENOTINITIALIZED; 07678 07679 list = (struct rsbac_list_lol_reg_item_t *) handle; 07680 if (list->self != list) 07681 return -RSBAC_EINVALIDLIST; 07682 07683 #ifdef CONFIG_RSBAC_LIST_TRANS 07684 if (ta_number) { 07685 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 07686 return -RSBAC_EINVALIDTRANSACTION; 07687 } 07688 #endif 07689 07690 rsbac_read_lock(&lol_reg_head.lock, &rlock_flags); 07691 /* 07692 rsbac_pr_debug(lists, "removing from list of lists %s.\n", list->name); 07693 */ 07694 rsbac_write_lock(&list->lock, &lock_flags); 07695 #ifdef CONFIG_RSBAC_LIST_TRANS 07696 for (i=0; i<list->nr_hashes; i++) { 07697 if (list->hashed[i].ta_copied) { 07698 if (ta_number && (list->hashed[i].ta_copied != ta_number)) { 07699 rsbac_write_unlock(&list->lock, &lock_flags); 07700 rsbac_read_unlock(&lol_reg_head.lock, 07701 &rlock_flags); 07702 return -RSBAC_EBUSY; 07703 } 07704 sublist = list->hashed[i].head; 07705 while (sublist) { 07706 remove_lol_subitem(list, sublist, subdesc); 07707 sublist = sublist->next; 07708 } 07709 } else { 07710 if (ta_number) { 07711 ta_lol_copy(ta_number, list, i); 07712 sublist = list->hashed[i].head; 07713 while (sublist) { 07714 remove_lol_subitem(list, sublist, subdesc); 07715 sublist = sublist->next; 07716 } 07717 } 07718 } 07719 } 07720 if (!ta_number) 07721 #endif 07722 { 07723 for (i=0; i<list->nr_hashes; i++) { 07724 sublist = list->hashed[i].head; 07725 while (sublist) { 07726 if (lookup_lol_subitem(list, sublist, subdesc)) { /* exists -> remove and set dirty */ 07727 remove_lol_subitem(list, sublist, subdesc); 07728 lol_touch(list); 07729 list->dirty = TRUE; 07730 } 07731 sublist = sublist->next; 07732 } 07733 } 07734 } 07735 rsbac_write_unlock(&list->lock, &lock_flags); 07736 rsbac_read_unlock(&lol_reg_head.lock, &rlock_flags); 07737 return 0; 07738 }
int rsbac_ta_list_remove | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle, | |||
void * | desc | |||
) |
Definition at line 7245 of file gen_lists.c.
References rsbac_list_reg_item_t::hash_function, rsbac_list_reg_item_t::hashed, list_initialized, rsbac_list_reg_head_t::lock, rsbac_list_reg_item_t::lock, lookup_item(), rsbac_list_reg_item_t::nr_hashes, reg_head, remove_item(), RSBAC_EBUSY, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_EINVALIDVALUE, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), rsbac_list_reg_item_t::self, touch, and TRUE.
Referenced by rsbac_acl_remove_acl_entry(), rsbac_acl_remove_group(), rsbac_acl_remove_subject(), rsbac_acl_remove_user(), rsbac_list_remove(), rsbac_pm_exists(), rsbac_pm_remove_target(), rsbac_rc_set_item(), rsbac_ta_remove_target(), rsbac_um_remove_group(), set_attr_fd(), and set_attr_user().
07247 { 07248 struct rsbac_list_reg_item_t *list; 07249 u_long lock_flags, rlock_flags; 07250 u_int hash = 0; 07251 07252 if (!handle) 07253 return -RSBAC_EINVALIDLIST; 07254 if (!desc) 07255 return -RSBAC_EINVALIDVALUE; 07256 if (!list_initialized) 07257 return -RSBAC_ENOTINITIALIZED; 07258 07259 list = (struct rsbac_list_reg_item_t *) handle; 07260 if (!list || (list->self != list)) 07261 return -RSBAC_EINVALIDLIST; 07262 07263 #ifdef CONFIG_RSBAC_LIST_TRANS 07264 if (ta_number) { 07265 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 07266 return -RSBAC_EINVALIDTRANSACTION; 07267 } 07268 #endif 07269 07270 rsbac_read_lock(®_head.lock, &rlock_flags); 07271 /* 07272 rsbac_pr_debug(lists, "removing from list %s.\n", list->name); 07273 */ 07274 if(list->hash_function) 07275 hash = list->hash_function(desc, list->nr_hashes); 07276 rsbac_write_lock(&list->lock, &lock_flags); 07277 #ifdef CONFIG_RSBAC_LIST_TRANS 07278 if (list->hashed[hash].ta_copied) { 07279 if (ta_number) { 07280 if (ta_lookup_item(list->hashed[hash].ta_copied, list, desc)) { 07281 if (list->hashed[hash].ta_copied != ta_number) { 07282 rsbac_write_unlock(&list->lock, 07283 &lock_flags); 07284 rsbac_read_unlock(®_head.lock, 07285 &rlock_flags); 07286 return -RSBAC_EBUSY; 07287 } else 07288 ta_remove_item(ta_number, list, 07289 desc); 07290 } 07291 } else 07292 ta_remove_item(list->hashed[hash].ta_copied, list, desc); 07293 } else { 07294 if (ta_number && lookup_item(list, desc)) { 07295 ta_copy(ta_number, list, hash); 07296 ta_remove_item(ta_number, list, desc); 07297 } 07298 } 07299 if (!ta_number) 07300 #endif 07301 { 07302 if (lookup_item(list, desc)) { /* exists -> remove */ 07303 remove_item(list, desc); 07304 touch(list); 07305 list->dirty = TRUE; 07306 } 07307 } 07308 rsbac_write_unlock(&list->lock, &lock_flags); 07309 rsbac_read_unlock(®_head.lock, &rlock_flags); 07310 return 0; 07311 }
int rsbac_ta_list_remove_all | ( | rsbac_list_ta_number_t | ta_number, | |
rsbac_list_handle_t | handle | |||
) |
Definition at line 7317 of file gen_lists.c.
References rsbac_list_reg_item_t::hashed, list_initialized, rsbac_list_reg_head_t::lock, rsbac_list_reg_item_t::lock, rsbac_list_reg_item_t::nr_hashes, reg_head, RSBAC_EBUSY, RSBAC_EINVALIDLIST, RSBAC_EINVALIDTRANSACTION, RSBAC_ENOTINITIALIZED, rsbac_ta_list_exist(), and rsbac_list_reg_item_t::self.
Referenced by rsbac_list_remove_all().
07319 { 07320 struct rsbac_list_reg_item_t *list; 07321 u_long lock_flags, rlock_flags; 07322 int i; 07323 07324 if (!handle) 07325 return -RSBAC_EINVALIDLIST; 07326 if (!list_initialized) 07327 return -RSBAC_ENOTINITIALIZED; 07328 07329 list = (struct rsbac_list_reg_item_t *) handle; 07330 if (list->self != list) 07331 return -RSBAC_EINVALIDLIST; 07332 07333 #ifdef CONFIG_RSBAC_LIST_TRANS 07334 if (ta_number) { 07335 if (!rsbac_ta_list_exist(0, ta_handle, &ta_number)) 07336 return -RSBAC_EINVALIDTRANSACTION; 07337 } 07338 #endif 07339 07340 rsbac_read_lock(®_head.lock, &rlock_flags); 07341 /* 07342 rsbac_pr_debug(lists, "removing all items from list %s.\n", list->name); 07343 */ 07344 rsbac_write_lock(&list->lock, &lock_flags); 07345 #ifdef CONFIG_RSBAC_LIST_TRANS 07346 for (i=0; i<list->nr_hashes; i++) { 07347 if (list->hashed[i].ta_copied) { 07348 if (ta_number) { 07349 if (list->hashed[i].ta_copied == ta_number) { 07350 ta_remove_all_items(list, i); 07351 if (!list->hashed[i].head) { 07352 list->hashed[i].ta_copied = 0; 07353 } 07354 } else { 07355 rsbac_write_unlock(&list->lock, 07356 &lock_flags); 07357 rsbac_read_unlock(®_head.lock, 07358 &rlock_flags); 07359 return -RSBAC_EBUSY; 07360 } 07361 } else 07362 ta_remove_all_items(list, i); 07363 } else { 07364 if (ta_number) { 07365 if (list->hashed[i].head) { 07366 list->hashed[i].ta_head = NULL; 07367 list->hashed[i].ta_tail = NULL; 07368 list->hashed[i].ta_curr = NULL; 07369 list->hashed[i].ta_count = 0; 07370 list->hashed[i].ta_copied = ta_number; 07371 } 07372 } 07373 } 07374 } 07375 07376 if (!ta_number) 07377 #endif 07378 for (i=0; i<list->nr_hashes; i++) 07379 if (list->hashed[i].head) { 07380 remove_all_items(list, i); 07381 touch(list); 07382 list->dirty = TRUE; 07383 } 07384 rsbac_write_unlock(&list->lock, &lock_flags); 07385 rsbac_read_unlock(®_head.lock, &rlock_flags); 07386 return 0; 07387 }
rsbac_boolean_t list_initialized = FALSE [static] |
Definition at line 34 of file gen_lists.c.
Referenced by rsbac_check_lists(), rsbac_list_check(), rsbac_list_destroy(), rsbac_list_detach(), rsbac_list_get_item_size(), rsbac_list_get_nr_hashes(), rsbac_list_init(), rsbac_list_lol_check(), rsbac_list_lol_destroy(), rsbac_list_lol_detach(), rsbac_list_lol_get_item_size(), rsbac_list_lol_get_nr_hashes(), rsbac_list_lol_get_subitem_size(), rsbac_list_lol_max_items(), rsbac_list_lol_no_write(), rsbac_list_lol_register_hashed(), rsbac_list_max_items(), rsbac_list_no_write(), rsbac_list_register_hashed(), rsbac_ta_list_add_ttl(), rsbac_ta_list_count(), rsbac_ta_list_exist(), rsbac_ta_list_get_all_data(), rsbac_ta_list_get_all_desc(), rsbac_ta_list_get_all_items_ttl(), rsbac_ta_list_get_data_ttl(), rsbac_ta_list_get_desc(), rsbac_ta_list_get_max_desc(), rsbac_ta_list_get_next_desc(), rsbac_ta_list_lol_add_ttl(), rsbac_ta_list_lol_all_subcount(), rsbac_ta_list_lol_count(), rsbac_ta_list_lol_exist(), rsbac_ta_list_lol_get_all_data(), rsbac_ta_list_lol_get_all_desc(), rsbac_ta_list_lol_get_all_items(), rsbac_ta_list_lol_get_all_subdata(), rsbac_ta_list_lol_get_all_subdesc_ttl(), rsbac_ta_list_lol_get_all_subitems_ttl(), rsbac_ta_list_lol_get_data_ttl(), rsbac_ta_list_lol_get_desc(), rsbac_ta_list_lol_get_max_subdesc(), rsbac_ta_list_lol_get_next_desc(), rsbac_ta_list_lol_get_subdata_ttl(), rsbac_ta_list_lol_remove(), rsbac_ta_list_lol_remove_all(), rsbac_ta_list_lol_subadd_ttl(), rsbac_ta_list_lol_subcount(), rsbac_ta_list_lol_subexist(), rsbac_ta_list_lol_subexist_compare(), rsbac_ta_list_lol_subremove(), rsbac_ta_list_lol_subremove_all(), rsbac_ta_list_lol_subremove_count(), rsbac_ta_list_lol_subremove_from_all(), rsbac_ta_list_remove(), and rsbac_ta_list_remove_all().
struct rsbac_list_lol_reg_head_t lol_reg_head [static] |
Definition at line 33 of file gen_lists.c.
Referenced by add_lol_reg(), lookup_lol_reg(), lookup_lol_reg_name(), remove_lol_reg(), rsbac_list_init(), rsbac_list_lol_check(), rsbac_list_lol_copy(), rsbac_list_lol_destroy(), rsbac_list_lol_detach(), rsbac_list_lol_max_items(), rsbac_list_lol_no_write(), rsbac_list_lol_register_hashed(), rsbac_list_register_hashed(), rsbac_ta_list_lol_add_ttl(), rsbac_ta_list_lol_all_subcount(), rsbac_ta_list_lol_exist(), rsbac_ta_list_lol_get_all_data(), rsbac_ta_list_lol_get_all_desc(), rsbac_ta_list_lol_get_all_items(), rsbac_ta_list_lol_get_all_subdata(), rsbac_ta_list_lol_get_all_subdesc_ttl(), rsbac_ta_list_lol_get_all_subitems_ttl(), rsbac_ta_list_lol_get_data_ttl(), rsbac_ta_list_lol_get_desc(), rsbac_ta_list_lol_get_max_subdesc(), rsbac_ta_list_lol_get_next_desc(), rsbac_ta_list_lol_get_subdata_ttl(), rsbac_ta_list_lol_remove(), rsbac_ta_list_lol_remove_all(), rsbac_ta_list_lol_subadd_ttl(), rsbac_ta_list_lol_subcount(), rsbac_ta_list_lol_subexist(), rsbac_ta_list_lol_subexist_compare(), rsbac_ta_list_lol_subremove(), rsbac_ta_list_lol_subremove_all(), rsbac_ta_list_lol_subremove_count(), and rsbac_ta_list_lol_subremove_from_all().
struct rsbac_list_reg_head_t reg_head [static] |
Definition at line 32 of file gen_lists.c.
Referenced by add_reg(), lookup_reg(), lookup_reg_name(), remove_reg(), rsbac_check_lists(), rsbac_list_auto_rehash(), rsbac_list_check(), rsbac_list_copy(), rsbac_list_destroy(), rsbac_list_detach(), rsbac_list_init(), rsbac_list_lol_register_hashed(), rsbac_list_max_items(), rsbac_list_no_write(), rsbac_list_register_hashed(), rsbac_ta_list_add_ttl(), rsbac_ta_list_exist(), rsbac_ta_list_get_all_data(), rsbac_ta_list_get_all_desc(), rsbac_ta_list_get_all_items_ttl(), rsbac_ta_list_get_data_ttl(), rsbac_ta_list_get_desc(), rsbac_ta_list_get_max_desc(), rsbac_ta_list_get_next_desc(), rsbac_ta_list_remove(), and rsbac_ta_list_remove_all().
u_int rsbac_list_lol_max_hashes = RSBAC_LIST_MIN_MAX_HASHES [static] |
Definition at line 37 of file gen_lists.c.
Referenced by rsbac_list_init(), and rsbac_list_lol_register_hashed().
u_int rsbac_list_max_hashes = RSBAC_LIST_MIN_MAX_HASHES [static] |
Definition at line 36 of file gen_lists.c.
Referenced by rsbac_list_auto_rehash(), rsbac_list_init(), and rsbac_list_register_hashed().