#include <linux/init.h>
#include <rsbac/rkmem.h>
#include <rsbac/lists.h>
#include <rsbac/repl_lists.h>
Go to the source code of this file.
#define RSBAC_LIST_AUTO_REHASH_TRIGGER 50 |
#define RSBAC_LIST_BUFFER_DATA_SIZE (RSBAC_LIST_BUFFER_SIZE - sizeof(struct rsbac_list_buffer_t)) |
#define RSBAC_LIST_BUFFER_SIZE 8192 |
Definition at line 211 of file gen_lists.h.
Referenced by check_buffer(), fill_buffer(), and fill_lol_buffer().
#define RSBAC_LIST_COUNTS_PROC_NAME "gen_lists_counts" |
#define RSBAC_LIST_DISK_OLD_VERSION 10002 |
#define RSBAC_LIST_DISK_VERSION 10003 |
Definition at line 26 of file gen_lists.h.
Referenced by do_read_list(), do_read_lol_list(), fill_buffer(), and fill_lol_buffer().
#define RSBAC_LIST_LOL_MAX_OLD_HASH 16 |
#define RSBAC_LIST_MAX_NR_ITEMS 50000 |
#define RSBAC_LIST_MAX_NR_ITEMS_LIMIT 1000000 |
Definition at line 24 of file gen_lists.h.
Referenced by create_lol_reg(), create_reg(), rsbac_list_lol_max_items(), and rsbac_list_max_items().
#define RSBAC_LIST_MAX_NR_SUBITEMS 50000 |
#define RSBAC_LIST_MAX_OLD_HASH 32 |
#define RSBAC_LIST_NONAME "(no name)" |
#define RSBAC_LIST_PROC_NAME "gen_lists" |
#define RSBAC_LIST_REHASH_INTERVAL 60 |
Definition at line 44 of file gen_lists.h.
#define RSBAC_LIST_TA_KEY 0xface99 |
typedef __u32 rsbac_list_count_t |
Definition at line 94 of file gen_lists.h.
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_hashed_t::head, rsbac_list_reg_head_t::head, rsbac_list_reg_item_t::info, list_initialized, rsbac_list_reg_item_t::lock, rsbac_list_reg_head_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 __init rsbac_list_init | ( | void | ) |
Definition at line 4966 of file gen_lists.c.
References rsbac_list_lol_reg_head_t::count, rsbac_list_reg_head_t::count, rsbac_list_lol_reg_head_t::curr, rsbac_list_reg_head_t::curr, get_error_name(), rsbac_list_lol_reg_head_t::head, rsbac_list_reg_head_t::head, list_initialized, rsbac_list_lol_reg_head_t::lock, rsbac_list_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_lol_reg_head_t::tail, rsbac_list_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_mount | ( | kdev_t | kdev | ) |
int rsbac_list_umount | ( | kdev_t | kdev | ) |