#include "dazukoio_xp.h"
Go to the source code of this file.
Data Structures | |
struct | event_properties |
struct | file_properties |
struct | dazuko_file_listnode |
struct | dazuko_file_struct |
Defines | |
#define | VERSION "2.0.5" |
#define | SET_ACCESS_MASK 0 |
#define | ADD_INCLUDE_PATH 1 |
#define | ADD_EXCLUDE_PATH 2 |
#define | REGISTER 3 |
#define | REMOVE_ALL_PATHS 4 |
#define | UNREGISTER 5 |
#define | GET_AN_ACCESS 6 |
#define | RETURN_AN_ACCESS 7 |
#define | DAZUKO_FREE 0 |
#define | DAZUKO_READY 1 |
#define | DAZUKO_WAITING 2 |
#define | DAZUKO_WORKING 3 |
#define | DAZUKO_DONE 4 |
#define | DAZUKO_BROKEN 5 |
#define | DAZUKO_NONE 0 |
#define | DAZUKO_REGULAR 1 |
#define | DAZUKO_DIRECTORY 2 |
#define | DAZUKO_LINK 3 |
#define | DPRINT(fmt) |
Functions | |
int | xp_init_mutex (struct xp_mutex *mutex) |
int | xp_down (struct xp_mutex *mutex) |
int | xp_up (struct xp_mutex *mutex) |
int | xp_destroy_mutex (struct xp_mutex *mutex) |
int | xp_init_rwlock (struct xp_rwlock *rwlock) |
int | xp_write_lock (struct xp_rwlock *rwlock) |
int | xp_write_unlock (struct xp_rwlock *rwlock) |
int | xp_read_lock (struct xp_rwlock *rlock) |
int | xp_read_unlock (struct xp_rwlock *rlock) |
int | xp_destroy_rwlock (struct xp_rwlock *rwlock) |
int | xp_init_queue (struct xp_queue *queue) |
int | xp_wait_until_condition (struct xp_queue *queue, int(*cfunction)(void *), void *cparam, int allow_interrupt) |
int | xp_notify (struct xp_queue *queue) |
int | xp_destroy_queue (struct xp_queue *queue) |
void * | xp_malloc (size_t size) |
int | xp_free (void *ptr) |
int | xp_copyin (const void *user_src, void *kernel_dest, size_t size) |
int | xp_copyout (const void *kernel_src, void *user_dest, size_t size) |
int | xp_verify_user_writable (const void *user_ptr, size_t size) |
int | xp_verify_user_readable (const void *user_ptr, size_t size) |
int | xp_is_absolute_path (const char *path) |
int | xp_atomic_set (struct xp_atomic *atomic, int value) |
int | xp_atomic_inc (struct xp_atomic *atomic) |
int | xp_atomic_dec (struct xp_atomic *atomic) |
int | xp_atomic_read (struct xp_atomic *atomic) |
int | xp_copy_file (struct xp_file *dest, struct xp_file *src) |
int | xp_compare_file (struct xp_file *file1, struct xp_file *file2) |
int | xp_sys_hook (void) |
int | xp_sys_unhook (void) |
int | xp_fill_file_struct (struct dazuko_file_struct *dfs) |
int | xp_id_compare (struct xp_daemon_id *id1, struct xp_daemon_id *id2) |
int | xp_id_free (struct xp_daemon_id *id) |
xp_daemon_id * | xp_id_copy (struct xp_daemon_id *id) |
int | xp_print (const char *fmt,...) |
int | dazuko_vsnprintf (char *str, size_t size, const char *format, va_list ap) |
int | dazuko_snprintf (char *str, size_t size, const char *format,...) |
int | dazuko_is_our_daemon (struct xp_daemon_id *xp_id) |
int | dazuko_get_value (const char *key, const char *string, char **value) |
int | dazuko_unregister_daemon (struct xp_daemon_id *xp_id) |
int | dazuko_handle_user_request (struct dazuko_request *user_request, struct xp_daemon_id *xp_id) |
int | dazuko_handle_user_request_compat12 (void *ptr, int cmd, struct xp_daemon_id *xp_id) |
int | dazuko_get_filename_length (char *filename) |
void | dazuko_bzero (void *p, int len) |
int | dazuko_sys_check (unsigned long event, int daemon_is_allowed, struct xp_daemon_id *xp_id) |
int | dazuko_sys_pre (unsigned long event, struct dazuko_file_struct *kfs, struct xp_file *file, struct event_properties *event_p) |
int | dazuko_sys_post (unsigned long event, struct dazuko_file_struct *kfs, struct xp_file *file, struct event_properties *event_p) |
int | dazuko_init (void) |
int | dazuko_exit (void) |
#define ADD_EXCLUDE_PATH 2 |
Definition at line 45 of file dazuko_xp.h.
#define ADD_INCLUDE_PATH 1 |
Definition at line 44 of file dazuko_xp.h.
#define DAZUKO_BROKEN 5 |
Definition at line 58 of file dazuko_xp.h.
#define DAZUKO_DIRECTORY 2 |
Definition at line 63 of file dazuko_xp.h.
#define DAZUKO_DONE 4 |
Definition at line 57 of file dazuko_xp.h.
#define DAZUKO_FREE 0 |
Definition at line 53 of file dazuko_xp.h.
#define DAZUKO_LINK 3 |
Definition at line 64 of file dazuko_xp.h.
#define DAZUKO_NONE 0 |
Definition at line 61 of file dazuko_xp.h.
#define DAZUKO_READY 1 |
Definition at line 54 of file dazuko_xp.h.
#define DAZUKO_REGULAR 1 |
Definition at line 62 of file dazuko_xp.h.
#define DAZUKO_WAITING 2 |
Definition at line 55 of file dazuko_xp.h.
#define DAZUKO_WORKING 3 |
Definition at line 56 of file dazuko_xp.h.
#define DPRINT | ( | fmt | ) |
Definition at line 202 of file dazuko_xp.h.
#define GET_AN_ACCESS 6 |
Definition at line 49 of file dazuko_xp.h.
#define REGISTER 3 |
Definition at line 46 of file dazuko_xp.h.
#define REMOVE_ALL_PATHS 4 |
Definition at line 47 of file dazuko_xp.h.
#define RETURN_AN_ACCESS 7 |
Definition at line 50 of file dazuko_xp.h.
#define SET_ACCESS_MASK 0 |
Definition at line 43 of file dazuko_xp.h.
#define UNREGISTER 5 |
Definition at line 48 of file dazuko_xp.h.
#define VERSION "2.0.5" |
void dazuko_bzero | ( | void * | p, | |
int | len | |||
) | [inline] |
Definition at line 306 of file dazuko_core.c.
00307 { 00308 /* "zero out" len bytes starting with p */ 00309 00310 char *ptr = (char *)p; 00311 00312 while (len--) 00313 *ptr++ = 0; 00314 }
int dazuko_exit | ( | void | ) | [inline] |
Definition at line 3458 of file dazuko_core.c.
References call_xp_atomic_read(), call_xp_destroy_mutex(), call_xp_destroy_queue(), call_xp_destroy_rwlock(), call_xp_free(), call_xp_print, call_xp_sys_unhook, dazuko_remove_all_hash(), dazuko_remove_all_paths(), dazuko_remove_all_trusted(), lock_hash, lock_lists, slot_list_container::mutex, mutex_amc, mutex_unique_count, NULL, NUM_SLOT_LISTS, NUM_SLOTS, slot_list::reg_name, rsbac_printk(), slot_list_container::slot_list, slot_lists, VERSION, VERSION_STRING, wait_daemon_waiting_for_free, wait_daemon_waiting_for_work, wait_kernel_waiting_for_free_slot, and wait_kernel_waiting_while_daemon_works.
03459 { 03460 int error; 03461 int i; 03462 int j; 03463 03464 i = call_xp_atomic_read(&active); 03465 03466 if (i != 0) 03467 { 03468 call_xp_print("dazuko: warning: trying to remove Dazuko with %d process%s still registered\n", i, i==1 ? "" : "es"); 03469 return -1; 03470 } 03471 03472 error = call_xp_sys_unhook(); 03473 03474 if (error == 0) 03475 { 03476 call_xp_destroy_mutex(&mutex_unique_count); 03477 call_xp_destroy_mutex(&mutex_amc); 03478 03479 for (i=0 ; i<NUM_SLOT_LISTS ; i++) 03480 { 03481 if (slot_lists[i].slot_list != NULL) 03482 { 03483 dazuko_remove_all_paths(slot_lists[i].slot_list); 03484 03485 if (call_xp_atomic_read(&(slot_lists[i].slot_list->use_count)) != 0) 03486 call_xp_print("dazuko: slot_list count was not 0 (possible bug)\n"); 03487 03488 for (j=0 ; j<NUM_SLOTS ; j++) 03489 { 03490 call_xp_destroy_mutex(&(slot_lists[i].slot_list->slots[j].mutex)); 03491 call_xp_destroy_queue(&(slot_lists[i].slot_list->slots[j].wait_daemon_waiting_until_this_slot_not_READY)); 03492 call_xp_destroy_queue(&(slot_lists[i].slot_list->slots[j].wait_kernel_waiting_until_this_slot_not_WAITING_and_not_WORKING)); 03493 call_xp_destroy_queue(&(slot_lists[i].slot_list->slots[j].wait_daemon_waiting_until_this_slot_not_DONE)); 03494 } 03495 03496 call_xp_destroy_rwlock(&(slot_lists[i].slot_list->lock_lists)); 03497 03498 #ifdef TRUSTED_APPLICATION_SUPPORT 03499 dazuko_remove_all_trusted(slot_lists[i].slot_list); 03500 call_xp_destroy_rwlock(&(slot_lists[i].slot_list->lock_trusted_list)); 03501 #endif 03502 03503 call_xp_destroy_queue(&(slot_lists[i].slot_list->wait_kernel_waiting_for_any_READY_slot_or_zero_use_count)); 03504 03505 if (slot_lists[i].slot_list->reg_name != NULL) 03506 call_xp_free(slot_lists[i].slot_list->reg_name); 03507 slot_lists[i].slot_list->reg_name = NULL; 03508 03509 call_xp_free(slot_lists[i].slot_list); 03510 slot_lists[i].slot_list = NULL; 03511 } 03512 03513 call_xp_destroy_mutex(&(slot_lists[i].mutex)); 03514 } 03515 03516 call_xp_print("dazuko: unloaded, version=%s\n", VERSION_STRING); 03517 } 03518 03519 return error; 03520 }
int dazuko_get_filename_length | ( | char * | filename | ) | [inline] |
Definition at line 2499 of file dazuko_xp.c.
02500 { 02501 int len; 02502 02503 for (len=0 ; filename[len] ; len++); 02504 02505 return len; 02506 }
int dazuko_get_value | ( | const char * | key, | |
const char * | string, | |||
char ** | value | |||
) |
Definition at line 1310 of file dazuko_core.c.
References call_xp_malloc(), dazuko_strlen(), dazuko_strstr(), and NULL.
01311 { 01312 const char *p1; 01313 const char *p2; 01314 int size; 01315 01316 if (value == NULL) 01317 return -1; 01318 01319 *value = NULL; 01320 01321 if (key == NULL || string == NULL) 01322 return -1; 01323 01324 p1 = dazuko_strstr(string, key); 01325 if (p1 == NULL) 01326 return -1; 01327 01328 p1 += dazuko_strlen(key); 01329 01330 for (p2=p1 ; *p2 && *p2!='\n' ; p2++) 01331 continue; 01332 01333 size = (p2 - p1) + 1; 01334 *value = call_xp_malloc(size); 01335 if (*value == NULL) 01336 return -1; 01337 01338 memcpy(*value, p1, size - 1); 01339 (*value)[size - 1] = 0; 01340 01341 return 0; 01342 }
int dazuko_handle_user_request | ( | struct dazuko_request * | user_request, | |
struct xp_daemon_id * | xp_id | |||
) |
Definition at line 1653 of file dazuko_xp.c.
References dazuko_request::buffer, dazuko_request::buffer_size, call_xp_copyin(), call_xp_copyout(), call_xp_free(), call_xp_malloc(), dazuko_handle_request(), NULL, dazuko_request::reply_buffer, dazuko_request::reply_buffer_size, dazuko_request::reply_buffer_size_used, dazuko_request::type, XP_ERROR_FAULT, and XP_ERROR_PERMISSION.
01654 { 01655 int error = 0; 01656 struct dazuko_request *request; 01657 struct dazuko_request *temp_request; 01658 01659 if (user_request == NULL || xp_id == NULL) 01660 return XP_ERROR_FAULT; 01661 01662 /* allocate kernel request */ 01663 request = (struct dazuko_request *)call_xp_malloc(sizeof(struct dazuko_request)); 01664 if (request == NULL) 01665 return XP_ERROR_FAULT; 01666 01667 /* use out0 now */ 01668 01669 /* allocate temp kernel request */ 01670 temp_request = (struct dazuko_request *)call_xp_malloc(sizeof(struct dazuko_request)); 01671 if (temp_request == NULL) 01672 { 01673 error = XP_ERROR_FAULT; 01674 goto dazuko_handle_user_request_out0; 01675 } 01676 01677 /* use out1 now */ 01678 01679 /* copy in the request */ 01680 if (call_xp_copyin(user_request, temp_request, sizeof(struct dazuko_request)) != 0) 01681 { 01682 error = XP_ERROR_FAULT; 01683 goto dazuko_handle_user_request_out1; 01684 } 01685 01686 memcpy(request->type, temp_request->type, sizeof(char[2])); 01687 request->buffer_size = temp_request->buffer_size; 01688 01689 /* sanity check */ 01690 if (request->buffer_size < 0 || request->buffer_size > 8192) 01691 { 01692 error = XP_ERROR_FAULT; 01693 goto dazuko_handle_user_request_out1; 01694 } 01695 01696 request->reply_buffer_size = temp_request->reply_buffer_size; 01697 01698 /* sanity check */ 01699 if (request->reply_buffer_size < 0 || request->reply_buffer_size > 8192) 01700 { 01701 error = XP_ERROR_PERMISSION; 01702 goto dazuko_handle_user_request_out1; 01703 } 01704 01705 /* allocate buffer */ 01706 request->buffer = (char *)call_xp_malloc(request->buffer_size + 1); 01707 if (request->buffer == NULL) 01708 { 01709 error = XP_ERROR_FAULT; 01710 goto dazuko_handle_user_request_out1; 01711 } 01712 01713 /* use out2 now */ 01714 01715 if (request->reply_buffer_size > 0) 01716 { 01717 /* allocate reply buffer */ 01718 request->reply_buffer = (char *)call_xp_malloc(request->reply_buffer_size + 1); 01719 if (request->reply_buffer == NULL) 01720 { 01721 error = XP_ERROR_FAULT; 01722 goto dazuko_handle_user_request_out2; 01723 } 01724 01725 /* use out3 now */ 01726 01727 request->reply_buffer_size_used = 0; 01728 } 01729 01730 /* copy the buffer from userspace to kernelspace */ 01731 if (call_xp_copyin(temp_request->buffer, request->buffer, request->buffer_size) != 0) 01732 { 01733 error = XP_ERROR_FAULT; 01734 goto dazuko_handle_user_request_out3; 01735 } 01736 01737 request->buffer[request->buffer_size] = 0; 01738 01739 error = dazuko_handle_request(request, xp_id); 01740 01741 if (error == 0 && request->reply_buffer_size > 0) 01742 { 01743 request->reply_buffer[request->reply_buffer_size] = 0; 01744 01745 temp_request->reply_buffer_size_used = request->reply_buffer_size_used; 01746 01747 if (call_xp_copyout(temp_request, user_request, sizeof(struct dazuko_request)) != 0) 01748 { 01749 error = XP_ERROR_FAULT; 01750 goto dazuko_handle_user_request_out3; 01751 } 01752 01753 if (request->reply_buffer_size_used > 0) 01754 { 01755 if (call_xp_copyout(request->reply_buffer, temp_request->reply_buffer, request->reply_buffer_size_used) != 0) 01756 { 01757 error = XP_ERROR_FAULT; 01758 goto dazuko_handle_user_request_out3; 01759 } 01760 } 01761 } 01762 01763 dazuko_handle_user_request_out3: 01764 if (request->reply_buffer_size > 0) 01765 call_xp_free(request->reply_buffer); 01766 dazuko_handle_user_request_out2: 01767 call_xp_free(request->buffer); 01768 dazuko_handle_user_request_out1: 01769 call_xp_free(temp_request); 01770 dazuko_handle_user_request_out0: 01771 call_xp_free(request); 01772 01773 return error; 01774 }
int dazuko_handle_user_request_compat12 | ( | void * | ptr, | |
int | cmd, | |||
struct xp_daemon_id * | xp_id | |||
) |
Definition at line 1776 of file dazuko_xp.c.
References call_xp_copyin(), call_xp_copyout(), call_xp_free(), call_xp_id_copy(), call_xp_id_free(), call_xp_malloc(), call_xp_up(), call_xp_verify_user_readable(), call_xp_verify_user_writable(), DAZUKO_FILENAME_MAX_LENGTH_COMPAT12, dazuko_get_an_access(), dazuko_register_daemon(), dazuko_return_access(), dazuko_set_option(), dazuko_state_error(), DAZUKO_WORKING, access_compat12::deny, slot::event, access_compat12::event, slot::event_p, access_compat12::filename, slot::filename, slot::filenamelength, event_properties::flags, IOCTL_GET_AN_ACCESS, IOCTL_RETURN_ACCESS, IOCTL_SET_OPTION, event_properties::mode, slot::mutex, NULL, access_compat12::o_flags, access_compat12::o_mode, event_properties::pid, access_compat12::pid, REGISTER, rsbac_printk(), event_properties::uid, access_compat12::uid, daemon_id::unique, XP_ERROR_FAULT, XP_ERROR_INTERRUPT, XP_ERROR_INVALID, and daemon_id::xp_id.
Referenced by linux_dazuko_device_ioctl().
01777 { 01778 struct access_compat12 *user_request12; 01779 struct access_compat12 *temp_request12; 01780 int error = 0; 01781 struct slot *s; 01782 char *k_param; 01783 struct daemon_id did; 01784 int temp_length; 01785 int temp_int; 01786 01787 if (ptr == NULL || xp_id == NULL) 01788 return XP_ERROR_FAULT; 01789 01790 did.xp_id = call_xp_id_copy(xp_id); 01791 did.unique = -1; 01792 01793 switch (cmd) 01794 { 01795 case IOCTL_GET_AN_ACCESS: 01796 /* The daemon is requesting a filename of a file 01797 * to scan. This code will wait until a filename 01798 * is available, or until we should be killed. 01799 * (killing is done if any errors occur as well 01800 * as when the user kills us) */ 01801 01802 user_request12 = (struct access_compat12 *)ptr; 01803 01804 error = call_xp_verify_user_writable(user_request12, sizeof(struct access_compat12)); 01805 if (error) 01806 { 01807 error = XP_ERROR_FAULT; 01808 break; 01809 } 01810 01811 /* DOWN? */ 01812 s = dazuko_get_an_access(&did); 01813 01814 if (s == NULL) 01815 { 01816 error = XP_ERROR_INTERRUPT; 01817 break; 01818 } 01819 01820 /* DOWN */ 01821 01822 /* Slot IS in WORKING state. Copy all the 01823 * necessary information to userspace structure. */ 01824 01825 if (s->filenamelength >= DAZUKO_FILENAME_MAX_LENGTH_COMPAT12) 01826 { 01827 /* filename length overflow :( */ 01828 01829 s->filename[DAZUKO_FILENAME_MAX_LENGTH_COMPAT12 - 1] = 0; 01830 temp_length = DAZUKO_FILENAME_MAX_LENGTH_COMPAT12; 01831 } 01832 else 01833 { 01834 temp_length = s->filenamelength + 1; 01835 } 01836 01837 temp_request12 = (struct access_compat12 *)call_xp_malloc(sizeof(struct access_compat12)); 01838 if (temp_request12 == NULL) 01839 { 01840 error = XP_ERROR_FAULT; 01841 } 01842 else if (call_xp_copyin(user_request12, temp_request12, sizeof(struct access_compat12)) != 0) 01843 { 01844 error = XP_ERROR_FAULT; 01845 } 01846 01847 if (error == 0) 01848 { 01849 temp_request12->event = s->event; 01850 temp_request12->o_flags = s->event_p.flags; 01851 temp_request12->o_mode = s->event_p.mode; 01852 temp_request12->uid = s->event_p.uid; 01853 temp_request12->pid = s->event_p.pid; 01854 memcpy(temp_request12->filename, s->filename, temp_length); 01855 01856 if (call_xp_copyout(temp_request12, user_request12, sizeof(struct access_compat12)) != 0) 01857 { 01858 error = XP_ERROR_FAULT; 01859 } 01860 } 01861 01862 call_xp_up(&(s->mutex)); 01863 /* UP */ 01864 01865 if (error) 01866 { 01867 dazuko_state_error(s, DAZUKO_WORKING); 01868 } 01869 01870 if (temp_request12 != NULL) 01871 { 01872 call_xp_free(temp_request12); 01873 } 01874 01875 break; 01876 01877 case IOCTL_RETURN_ACCESS: 01878 /* The daemon has finished scanning a file 01879 * and has the response to give. The daemon's 01880 * slot should be in the WORKING state. */ 01881 01882 user_request12 = (struct access_compat12 *)ptr; 01883 01884 error = call_xp_verify_user_readable(user_request12, sizeof(struct access_compat12)); 01885 if (error) 01886 { 01887 error = XP_ERROR_FAULT; 01888 break; 01889 } 01890 01891 temp_request12 = (struct access_compat12 *)call_xp_malloc(sizeof(struct access_compat12)); 01892 if (temp_request12 == NULL) 01893 { 01894 error = XP_ERROR_FAULT; 01895 break; 01896 } 01897 01898 if (call_xp_copyin(user_request12, temp_request12, sizeof(struct access_compat12)) != 0) 01899 { 01900 error = XP_ERROR_FAULT; 01901 } 01902 01903 temp_int = temp_request12->deny; 01904 01905 call_xp_free(temp_request12); 01906 01907 error = dazuko_return_access(&did, temp_int, NULL); 01908 break; 01909 01910 case IOCTL_SET_OPTION: 01911 /* The daemon wants to set a configuration 01912 * option in the kernel. */ 01913 01914 error = call_xp_verify_user_readable(ptr, 2*sizeof(int)); 01915 if (error) 01916 { 01917 error = XP_ERROR_FAULT; 01918 break; 01919 } 01920 01921 /* copy option type from userspace */ 01922 if (call_xp_copyin(ptr, &temp_int, sizeof(int)) != 0) 01923 { 01924 error = XP_ERROR_FAULT; 01925 break; 01926 } 01927 01928 ptr = ((char *)ptr + sizeof(int)); 01929 01930 /* copy path length from userspace */ 01931 if (call_xp_copyin(ptr, &temp_length, sizeof(int)) != 0) 01932 { 01933 error = XP_ERROR_FAULT; 01934 break; 01935 } 01936 01937 /* sanity check */ 01938 if (temp_length < 0 || temp_length > 4096) 01939 { 01940 error = XP_ERROR_INVALID; 01941 break; 01942 } 01943 01944 ptr = ((char *)ptr + sizeof(int)); 01945 01946 error = call_xp_verify_user_readable(ptr, temp_length); 01947 if (error) 01948 { 01949 error = XP_ERROR_FAULT; 01950 break; 01951 } 01952 01953 k_param = (char *)call_xp_malloc(temp_length + 1); 01954 if (k_param == NULL) 01955 { 01956 error = XP_ERROR_FAULT; 01957 break; 01958 } 01959 01960 /* We must copy the param from userspace to kernelspace. */ 01961 01962 if (call_xp_copyin(ptr, k_param, temp_length) != 0) 01963 { 01964 call_xp_free(k_param); 01965 error = XP_ERROR_FAULT; 01966 break; 01967 } 01968 01969 k_param[temp_length] = 0; 01970 01971 if (temp_int == REGISTER) 01972 error = dazuko_register_daemon(&did, k_param, temp_length, 1); 01973 else 01974 error = dazuko_set_option(&did, temp_int, k_param, temp_length); 01975 01976 call_xp_free(k_param); 01977 01978 break; 01979 01980 default: 01981 rsbac_printk(KERN_INFO "dazuko: daemon requested unknown device_ioctl %d (possible bug)\n", cmd); 01982 01983 break; 01984 } 01985 01986 call_xp_id_free(did.xp_id); 01987 01988 return error; 01989 }
int dazuko_init | ( | void | ) | [inline] |
Definition at line 3432 of file dazuko_core.c.
References access_mask_cache, AMC_UNSET, call_xp_atomic_set(), call_xp_init_mutex(), call_xp_init_queue(), call_xp_init_rwlock(), call_xp_print, call_xp_sys_hook, dazuko_bzero(), groupcount, lock_hash, lock_lists, mutex_amc, mutex_unique_count, NUM_SLOT_LISTS, rsbac_printk(), slot_lists, VERSION, VERSION_STRING, wait_daemon_waiting_for_free, wait_daemon_waiting_for_work, wait_kernel_waiting_for_free_slot, and wait_kernel_waiting_while_daemon_works.
03433 { 03434 int i; 03435 int error; 03436 03437 call_xp_init_mutex(&mutex_unique_count); 03438 call_xp_init_mutex(&mutex_amc); 03439 03440 dazuko_bzero(&slot_lists, sizeof(slot_lists)); 03441 03442 memset(&access_mask_cache, AMC_UNSET, sizeof(access_mask_cache)); 03443 03444 for (i=0 ; i<NUM_SLOT_LISTS ; i++) 03445 call_xp_init_mutex(&(slot_lists[i].mutex)); 03446 03447 call_xp_atomic_set(&active, 0); 03448 call_xp_atomic_set(&groupcount, 0); 03449 03450 error = call_xp_sys_hook(); 03451 03452 if (error == 0) 03453 call_xp_print("dazuko: loaded, version=%s\n", VERSION_STRING); 03454 03455 return error; 03456 }
int dazuko_is_our_daemon | ( | struct xp_daemon_id * | xp_id | ) | [inline] |
Definition at line 2218 of file dazuko_xp.c.
References call_xp_id_copy(), call_xp_id_free(), dazuko_find_slot(), NULL, daemon_id::unique, and daemon_id::xp_id.
02219 { 02220 /* Check if the current process is one 02221 * of the daemons. */ 02222 02223 struct daemon_id did; 02224 int ret; 02225 02226 did.xp_id = call_xp_id_copy(xp_id); 02227 did.unique = -1; 02228 02229 ret = (dazuko_find_slot(&did, 1, NULL) != NULL); 02230 02231 call_xp_id_free(did.xp_id); 02232 02233 return ret; 02234 }
int dazuko_snprintf | ( | char * | str, | |
size_t | size, | |||
const char * | format, | |||
... | ||||
) |
Definition at line 294 of file dazuko_core.c.
References dazuko_vsnprintf().
00295 { 00296 va_list ap; 00297 int ret; 00298 00299 va_start(ap, format); 00300 ret = dazuko_vsnprintf(str, size, format, ap); 00301 va_end(ap); 00302 00303 return ret; 00304 }
int dazuko_sys_check | ( | unsigned long | event, | |
int | daemon_is_allowed, | |||
struct xp_daemon_id * | xp_id | |||
) | [inline] |
Definition at line 2563 of file dazuko_xp.c.
References access_mask, call_xp_atomic_read(), dazuko_is_our_daemon(), DAZUKO_ON_CLOSE, DAZUKO_ON_OPEN, SCAN_ON_CLOSE, SCAN_ON_CLOSE_MODIFIED, and SCAN_ON_OPEN.
Referenced by rsbac_adf_request_daz(), and rsbac_adf_set_attr_daz().
02564 { 02565 /* is this event in our mask? */ 02566 switch (event) 02567 { 02568 case DAZUKO_ON_OPEN: 02569 /* this is a special case because the on_close information needs 02570 * to be saved during the on_open event */ 02571 02572 if ((SCAN_ON_OPEN || SCAN_ON_CLOSE || SCAN_ON_CLOSE_MODIFIED) == 0) 02573 return -1; 02574 break; 02575 02576 case DAZUKO_ON_CLOSE: 02577 /* will need to scan if ON_CLOSE_MODIFIED is in the mask too */ 02578 02579 if ((SCAN_ON_CLOSE || SCAN_ON_CLOSE_MODIFIED) == 0) 02580 return -1; 02581 break; 02582 02583 default: 02584 if ((access_mask & event) == 0) 02585 return -1; 02586 break; 02587 } 02588 02589 /* do we have any daemons? */ 02590 if (call_xp_atomic_read(&active) <= 0) 02591 return -1; 02592 02593 /* should daemons be allowed this event without a scan? */ 02594 if (daemon_is_allowed) 02595 { 02596 if (dazuko_is_our_daemon(xp_id)) 02597 { 02598 /* this is one of our daemons, so we will report as 02599 * as if this event was not in the mask */ 02600 02601 return -1; 02602 } 02603 } 02604 02605 return 0; 02606 }
int dazuko_sys_post | ( | unsigned long | event, | |
struct dazuko_file_struct * | kfs, | |||
struct xp_file * | file, | |||
struct event_properties * | event_p | |||
) | [inline] |
Definition at line 2727 of file dazuko_xp.c.
References call_xp_atomic_read(), call_xp_free(), dazuko_add_hash(), dazuko_get_hash(), dazuko_mark_hash_dirty(), DAZUKO_ON_CLOSE, DAZUKO_ON_CLOSE_MODIFIED, DAZUKO_ON_OPEN, dazuko_run_daemon(), dazuko_should_scan(), hash::dirty, hash::file, hash, hash::name, hash::namelen, NULL, SCAN_ON_CLOSE, SCAN_ON_CLOSE_MODIFIED, and SCAN_ON_OPEN.
Referenced by rsbac_adf_set_attr_daz().
02728 { 02729 struct hash *h = NULL; 02730 02731 switch (event) 02732 { 02733 case DAZUKO_ON_OPEN: /* kfs,file required */ 02734 /* if the file was opened and we are interested 02735 * in scanning on close, add this file to our struct hash list */ 02736 02737 if ((call_xp_atomic_read(&active) > 0) && file != NULL && kfs != NULL) 02738 { 02739 if (SCAN_ON_OPEN || SCAN_ON_CLOSE || SCAN_ON_CLOSE_MODIFIED) 02740 { 02741 /* make sure we should scan this file */ 02742 if (dazuko_should_scan(kfs)) 02743 { 02744 /* hash is added if we were given an xp_file */ 02745 if (file != NULL) 02746 dazuko_add_hash(file, kfs->filename, kfs->filename_length); 02747 02748 /* this is a fallback in case we didn't process the event in "sys_pre" */ 02749 dazuko_run_daemon(event, kfs->filename, kfs->filename_length, event_p, &(kfs->file_p)); 02750 } 02751 } 02752 } 02753 break; 02754 02755 case DAZUKO_ON_CLOSE: /* file,o_flags,o_mode,pid,uid required */ 02756 if (file != NULL) 02757 { 02758 /* find hash entry and remove it from list */ 02759 h = dazuko_get_hash(file); 02760 02761 /* if we found the file in our list and the file was 02762 * successfully closed, we need to scan it */ 02763 if (h != NULL) 02764 { 02765 /* determine if we are scanning on close or close_modified */ 02766 02767 /* note that close_modified has priority over just close */ 02768 02769 if (SCAN_ON_CLOSE_MODIFIED && h->dirty) 02770 dazuko_run_daemon(DAZUKO_ON_CLOSE_MODIFIED, h->name, h->namelen, event_p, NULL); 02771 else if (SCAN_ON_CLOSE) 02772 dazuko_run_daemon(DAZUKO_ON_CLOSE, h->name, h->namelen, event_p, NULL); 02773 02774 /* clean up the struct hash structure */ 02775 call_xp_free(h); 02776 } 02777 } 02778 else 02779 { 02780 if (SCAN_ON_CLOSE) 02781 { 02782 if (dazuko_should_scan(kfs)) 02783 { 02784 dazuko_run_daemon(DAZUKO_ON_CLOSE, kfs->filename, kfs->filename_length, event_p, &(kfs->file_p)); 02785 } 02786 } 02787 } 02788 break; 02789 02790 case DAZUKO_ON_CLOSE_MODIFIED: /* file required */ 02791 if (file != NULL) 02792 { 02793 /* if we actually wrote something and we found the 02794 * file in our list, set it as dirty */ 02795 02796 /* Swade 4/24/02: Move to end of clean list */ 02797 dazuko_mark_hash_dirty(file); 02798 } 02799 break; 02800 02801 default: 02802 break; 02803 } 02804 02805 return 0; 02806 }
int dazuko_sys_pre | ( | unsigned long | event, | |
struct dazuko_file_struct * | kfs, | |||
struct xp_file * | file, | |||
struct event_properties * | event_p | |||
) | [inline] |
Definition at line 2608 of file dazuko_xp.c.
References call_xp_compare_file(), call_xp_malloc(), call_xp_read_lock(), DAZUKO_ON_CLOSE, DAZUKO_ON_CLOSE_MODIFIED, DAZUKO_ON_OPEN, hash::file, dazuko_file_struct::filename, dazuko_file_struct::filename_length, hash, lock_hash, hash::name, hash::namelen, hash::next, NULL, rsbac_printk(), SCAN_ON_OPEN, dazuko_file_struct::should_scan, and XP_ERROR_PERMISSION.
Referenced by rsbac_adf_request_daz().
02609 { 02610 /* return codes: 02611 * >0 -> access should be blocked 02612 * <0 -> access should be blocked (because user interrupted) 02613 * 0 -> access is allowed 02614 * -2 -> unscanned access should not be taken care of 02615 */ 02616 02617 int error = 0; 02618 struct hash *h = NULL; 02619 02620 switch (event) 02621 { 02622 case DAZUKO_ON_OPEN: 02623 /* special case, because this pre may be called 02624 * in order to record ON_CLOSE events (in post) */ 02625 02626 if (!SCAN_ON_OPEN) 02627 return 2; 02628 break; 02629 02630 case DAZUKO_ON_CLOSE: 02631 /* handled in post */ 02632 02633 return 2; 02634 02635 case DAZUKO_ON_CLOSE_MODIFIED: 02636 /* (this is really sys_write) always permitted */ 02637 02638 return 2; 02639 02640 default: 02641 break; 02642 } 02643 02644 if (kfs == NULL) 02645 { 02646 /* kfs is required */ 02647 02648 rsbac_printk(KERN_WARNING "dazuko: kfs=NULL (possible bug)\n"); 02649 02650 return XP_ERROR_PERMISSION; 02651 } 02652 02653 if (file != NULL) 02654 { 02655 /* we search for the file descriptor first */ 02656 02657 /* LOCK */ 02658 call_xp_read_lock(&lock_hash); 02659 02660 for (h=hash ; h ; h=h->next) 02661 { 02662 if (call_xp_compare_file(&(h->file), file) == 0) 02663 { 02664 /* we found the file descriptor */ 02665 02666 kfs->filename = (char*)call_xp_malloc(h->namelen + 1); 02667 if (kfs->filename != NULL) 02668 { 02669 memcpy(kfs->filename, h->name, h->namelen); 02670 kfs->filename[h->namelen] = 0; 02671 kfs->filename_length = h->namelen; 02672 kfs->should_scan = 1; 02673 } 02674 else 02675 { 02676 /* error allocating, so we get out */ 02677 h = NULL; 02678 } 02679 break; 02680 } 02681 } 02682 02683 call_xp_read_unlock(&lock_hash); 02684 /* UNLOCK */ 02685 02686 if (h == NULL && kfs->extra_data == NULL) 02687 { 02688 /* we don't know this file descriptor 02689 * and we cannot fallback on name lookups 02690 */ 02691 02692 /* we should not scan this file */ 02693 kfs->should_scan = 2; 02694 02695 return 0; 02696 } 02697 } 02698 02699 /* make sure we should scan this file */ 02700 if (dazuko_should_scan(kfs)) 02701 error = dazuko_run_daemon(event, kfs->filename, kfs->filename_length, event_p, &(kfs->file_p)); 02702 else 02703 return 2; 02704 02705 if (error > 0) 02706 { 02707 /* access will be blocked */ 02708 02709 /* dazuko_sys_post should NOT be called! */ 02710 02711 return XP_ERROR_PERMISSION; 02712 } 02713 else if (error < 0) 02714 { 02715 /* user interrupted */ 02716 02717 /* dazuko_sys_post should NOT be called! */ 02718 02719 return XP_ERROR_INTERRUPT; 02720 } 02721 02722 /* access allowed */ 02723 02724 return 0; 02725 }
int dazuko_unregister_daemon | ( | struct xp_daemon_id * | xp_id | ) |
Definition at line 834 of file dazuko_core.c.
References _dazuko_unregister_daemon(), call_xp_id_copy(), call_xp_id_free(), NULL, daemon_id::unique, and daemon_id::xp_id.
00835 { 00836 struct daemon_id did; 00837 int ret; 00838 00839 if (xp_id == NULL) 00840 return 0; 00841 00842 did.unique = -1; 00843 did.xp_id = call_xp_id_copy(xp_id); 00844 00845 ret = _dazuko_unregister_daemon(&did); 00846 00847 call_xp_id_free(did.xp_id); 00848 00849 return ret; 00850 }
int dazuko_vsnprintf | ( | char * | str, | |
size_t | size, | |||
const char * | format, | |||
va_list | ap | |||
) |
Definition at line 176 of file dazuko_core.c.
References DAZUKO_VSNPRINTF_PRINTSTRING, and NULL.
00177 { 00178 char *target; 00179 const char *end; 00180 int overflow = 0; 00181 char number_buffer[32]; /* 32 should be enough to hold any number, right? */ 00182 const char *s; 00183 00184 if (str == NULL || size < 1 || format == NULL) 00185 return -1; 00186 00187 target = str; 00188 end = (target + size) - 1; 00189 00190 #define DAZUKO_VSNPRINTF_PRINTSTRING \ 00191 for ( ; *s ; s++) \ 00192 { \ 00193 if (target == end) \ 00194 { \ 00195 overflow = 1; \ 00196 goto dazuko_vsnprintf_out; \ 00197 } \ 00198 *target = *s; \ 00199 target++; \ 00200 } 00201 00202 for ( ; *format ; format++) 00203 { 00204 if (target == end) 00205 { 00206 overflow = 1; 00207 goto dazuko_vsnprintf_out; 00208 } 00209 00210 if (*format == '%') 00211 { 00212 format++; 00213 00214 switch (*format) 00215 { 00216 case 's': /* %s */ 00217 s = va_arg(ap, char *); 00218 if (s == NULL) 00219 s = "(null)"; 00220 DAZUKO_VSNPRINTF_PRINTSTRING 00221 break; 00222 00223 case 'd': /* %d */ 00224 sprintf(number_buffer, "%d", va_arg(ap, int)); 00225 s = number_buffer; 00226 DAZUKO_VSNPRINTF_PRINTSTRING 00227 break; 00228 00229 case 'p': /* %p */ 00230 sprintf(number_buffer, "%p", va_arg(ap, void *)); 00231 s = number_buffer; 00232 DAZUKO_VSNPRINTF_PRINTSTRING 00233 break; 00234 00235 case 'c': /* %c */ 00236 *target = va_arg(ap, int); 00237 target++; 00238 break; 00239 00240 case 'l': /* %lu */ 00241 format++; 00242 if (*format != 'u') 00243 { 00244 /* print error message */ 00245 goto dazuko_vsnprintf_out; 00246 } 00247 sprintf(number_buffer, "%lu", va_arg(ap, unsigned long)); 00248 s = number_buffer; 00249 DAZUKO_VSNPRINTF_PRINTSTRING 00250 break; 00251 00252 case '0': /* %02x */ 00253 format++; 00254 if (*format != '2') 00255 { 00256 /* print error message */ 00257 goto dazuko_vsnprintf_out; 00258 } 00259 format++; 00260 if (*format != 'x') 00261 { 00262 /* print error message */ 00263 goto dazuko_vsnprintf_out; 00264 } 00265 sprintf(number_buffer, "%02x", va_arg(ap, int)); 00266 s = number_buffer; 00267 DAZUKO_VSNPRINTF_PRINTSTRING 00268 break; 00269 00270 default: 00271 /* print error message */ 00272 goto dazuko_vsnprintf_out; 00273 } 00274 } 00275 else 00276 { 00277 *target = *format; 00278 target++; 00279 } 00280 } 00281 00282 dazuko_vsnprintf_out: 00283 00284 *target = 0; 00285 00286 /* We are returning what we've written. If there was an 00287 * overflow, the returned value will match "size" rather 00288 * than being less than "size" 00289 */ 00290 00291 return ((target - str) + overflow); 00292 }
int xp_atomic_dec | ( | struct xp_atomic * | atomic | ) | [inline] |
Definition at line 313 of file daz_main.c.
References xp_atomic::atomic.
00314 { 00315 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) 00316 #ifdef MODULE 00317 if (atomic == &active) 00318 MOD_DEC_USE_COUNT; 00319 #endif 00320 #endif 00321 00322 atomic_dec(&(atomic->atomic)); 00323 return 0; 00324 }
int xp_atomic_inc | ( | struct xp_atomic * | atomic | ) | [inline] |
Definition at line 300 of file daz_main.c.
References xp_atomic::atomic.
00301 { 00302 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) 00303 #ifdef MODULE 00304 if (atomic == &active) 00305 MOD_INC_USE_COUNT; 00306 #endif 00307 #endif 00308 00309 atomic_inc(&(atomic->atomic)); 00310 return 0; 00311 }
int xp_atomic_read | ( | struct xp_atomic * | atomic | ) | [inline] |
Definition at line 326 of file daz_main.c.
References xp_atomic::atomic.
00327 { 00328 return atomic_read(&(atomic->atomic)); 00329 }
int xp_atomic_set | ( | struct xp_atomic * | atomic, | |
int | value | |||
) | [inline] |
Definition at line 294 of file daz_main.c.
References xp_atomic::atomic.
00295 { 00296 atomic_set(&(atomic->atomic), value); 00297 return 0; 00298 }
int xp_copyin | ( | const void * | user_src, | |
void * | kernel_dest, | |||
size_t | size | |||
) | [inline] |
int xp_copyout | ( | const void * | kernel_src, | |
void * | user_dest, | |||
size_t | size | |||
) | [inline] |
int xp_destroy_mutex | ( | struct xp_mutex * | mutex | ) | [inline] |
int xp_destroy_queue | ( | struct xp_queue * | queue | ) | [inline] |
int xp_destroy_rwlock | ( | struct xp_rwlock * | rwlock | ) | [inline] |
int xp_down | ( | struct xp_mutex * | mutex | ) | [inline] |
Definition at line 158 of file daz_main.c.
References xp_mutex::mutex.
00159 { 00160 down(&(mutex->mutex)); 00161 return 0; 00162 }
int xp_fill_file_struct | ( | struct dazuko_file_struct * | dfs | ) | [inline] |
Definition at line 344 of file daz_main.c.
References dazuko_get_filename_length(), xp_file_struct::dentry, file_properties::device_type, dazuko_file_struct::extra_data, dazuko_file_struct::file_p, dazuko_file_struct::filename, dazuko_file_struct::filename_length, xp_file_struct::free_full_filename, xp_file_struct::full_filename, xp_file_struct::full_filename_length, file_properties::gid, file_properties::mode, NULL, rsbac_get_full_path(), rsbac_get_full_path_length(), file_properties::set_device_type, file_properties::set_gid, file_properties::set_mode, file_properties::set_size, file_properties::set_uid, file_properties::size, file_properties::uid, and xp_malloc().
00345 { 00346 int length; 00347 00348 /* make sure we have access to everything */ 00349 00350 if (dfs == NULL) 00351 return -1; 00352 00353 if (dfs->extra_data == NULL) 00354 return -1; 00355 00356 if (dfs->extra_data->dentry == NULL) 00357 return -1; 00358 00359 if (dfs->extra_data->dentry->d_inode == NULL) 00360 return -1; 00361 00362 /* ok, we have everything we need */ 00363 00364 length = rsbac_get_full_path_length(dfs->extra_data->dentry); 00365 if (length < 1) 00366 return -1; 00367 00368 dfs->extra_data->full_filename = xp_malloc(length + 1); 00369 if (dfs->extra_data->full_filename == NULL) 00370 return -1; 00371 00372 /* the full_filename will need to be deleted later */ 00373 dfs->extra_data->free_full_filename = 1; 00374 00375 if (rsbac_get_full_path(dfs->extra_data->dentry, dfs->extra_data->full_filename, length + 1) < 1) 00376 return -1; 00377 00378 /* find the actual value of the length */ 00379 dfs->extra_data->full_filename_length = dazuko_get_filename_length(dfs->extra_data->full_filename); 00380 00381 /* reference copy of full path */ 00382 dfs->filename = dfs->extra_data->full_filename; 00383 00384 dfs->filename_length = dfs->extra_data->full_filename_length; 00385 00386 dfs->file_p.size = dfs->extra_data->dentry->d_inode->i_size; 00387 dfs->file_p.set_size = 1; 00388 dfs->file_p.uid = dfs->extra_data->dentry->d_inode->i_uid; 00389 dfs->file_p.set_uid = 1; 00390 dfs->file_p.gid = dfs->extra_data->dentry->d_inode->i_gid; 00391 dfs->file_p.set_gid = 1; 00392 dfs->file_p.mode = dfs->extra_data->dentry->d_inode->i_mode; 00393 dfs->file_p.set_mode = 1; 00394 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) 00395 dfs->file_p.device_type = dfs->extra_data->dentry->d_inode->i_dev; 00396 #else 00397 dfs->file_p.device_type = dfs->extra_data->dentry->d_inode->i_rdev; 00398 #endif 00399 dfs->file_p.set_device_type = 1; 00400 00401 return 0; 00402 }
int xp_free | ( | void * | ptr | ) | [inline] |
int xp_id_compare | ( | struct xp_daemon_id * | id1, | |
struct xp_daemon_id * | id2 | |||
) |
Definition at line 430 of file daz_main.c.
References xp_daemon_id::file, NULL, and xp_daemon_id::pid.
00431 { 00432 if (id1 == NULL || id2 == NULL) 00433 return -1; 00434 00435 /* if file's are available and they match, 00436 * then we say that the id's match */ 00437 if (id1->file != NULL && id1->file == id2->file) 00438 return 0; 00439 00440 if (id1->pid == id2->pid) 00441 return 0; 00442 00443 return 1; 00444 }
struct xp_daemon_id* xp_id_copy | ( | struct xp_daemon_id * | id | ) | [inline] |
Definition at line 453 of file daz_main.c.
References xp_daemon_id::file, NULL, xp_daemon_id::pid, and xp_malloc().
00454 { 00455 struct xp_daemon_id *ptr; 00456 00457 if (id == NULL) 00458 return NULL; 00459 00460 ptr = (struct xp_daemon_id *)xp_malloc(sizeof(struct xp_daemon_id)); 00461 00462 if (ptr != NULL) 00463 { 00464 ptr->pid = id->pid; 00465 ptr->file = id->file; 00466 } 00467 00468 return ptr; 00469 }
int xp_id_free | ( | struct xp_daemon_id * | id | ) | [inline] |
Definition at line 446 of file daz_main.c.
References xp_free().
00447 { 00448 xp_free(id); 00449 00450 return 0; 00451 }
int xp_init_mutex | ( | struct xp_mutex * | mutex | ) | [inline] |
Definition at line 147 of file daz_main.c.
References xp_mutex::mutex.
00148 { 00149 #ifdef init_MUTEX 00150 init_MUTEX(&(mutex->mutex)); 00151 #else 00152 sema_init(&(mutex->mutex), 1); 00153 #endif 00154 00155 return 0; 00156 }
int xp_init_queue | ( | struct xp_queue * | queue | ) | [inline] |
Definition at line 216 of file daz_main.c.
References xp_queue::queue.
00217 { 00218 init_waitqueue_head(&(queue->queue)); 00219 return 0; 00220 }
int xp_init_rwlock | ( | struct xp_rwlock * | rwlock | ) | [inline] |
Definition at line 178 of file daz_main.c.
References xp_rwlock::rwlock.
00179 { 00180 rwlock_init(&(rwlock->rwlock)); 00181 return 0; 00182 }
int xp_is_absolute_path | ( | const char * | path | ) | [inline] |
void* xp_malloc | ( | size_t | size | ) | [inline] |
Definition at line 252 of file daz_main.c.
References rsbac_kmalloc().
00253 { 00254 return rsbac_kmalloc(size); 00255 }
int xp_notify | ( | struct xp_queue * | queue | ) | [inline] |
Definition at line 238 of file daz_main.c.
References xp_queue::queue.
00239 { 00240 wake_up(&(queue->queue)); 00241 return 0; 00242 }
int xp_print | ( | const char * | fmt, | |
... | ||||
) |
Definition at line 1791 of file dazuko_linux.c.
References dazuko_vsnprintf(), rsbac_printk(), xp_free(), and xp_malloc().
01792 { 01793 va_list args; 01794 char *p; 01795 size_t size = 1024; 01796 01797 p = (char *)xp_malloc(size); 01798 if (!p) 01799 return -1; 01800 01801 va_start(args, fmt); 01802 dazuko_vsnprintf(p, size-1, fmt, args); 01803 va_end(args); 01804 01805 p[size-1] = 0; 01806 01807 printk(p); 01808 01809 xp_free(p); 01810 01811 return 0; 01812 }
int xp_read_lock | ( | struct xp_rwlock * | rlock | ) | [inline] |
Definition at line 196 of file daz_main.c.
References xp_rwlock::rwlock.
00197 { 00198 read_lock(&(rlock->rwlock)); 00199 return 0; 00200 }
int xp_read_unlock | ( | struct xp_rwlock * | rlock | ) | [inline] |
Definition at line 202 of file daz_main.c.
References xp_rwlock::rwlock.
00203 { 00204 read_unlock(&(rlock->rwlock)); 00205 return 0; 00206 }
int xp_sys_hook | ( | void | ) | [inline] |
Definition at line 474 of file daz_main.c.
References dazuko_class, dev_major, DEVICE_NAME, fops, NULL, rsbac_printk(), and xp_print().
00475 { 00476 int wanted_major = CONFIG_RSBAC_DAZ_DEV_MAJOR; 00477 00478 /* Called from insmod when inserting the module. */ 00479 /* register the dazuko device */ 00480 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 00481 if((wanted_major > 0) && (wanted_major <= 254)) { 00482 dev_major = register_chrdev(wanted_major, DEVICE_NAME, &fops); 00483 if (dev_major < 0) { 00484 rsbac_printk(KERN_WARNING "dazuko: unable to register major chrdev %u, err=%d\n", 00485 wanted_major, dev_major); 00486 return dev_major; 00487 } 00488 dev_major = wanted_major; 00489 dazuko_class = class_create(THIS_MODULE, "dazuko"); 00490 class_device_create(dazuko_class, NULL, 00491 MKDEV(wanted_major, 0), 00492 NULL, "dazuko"); 00493 } else { 00494 dev_major = register_chrdev(0, DEVICE_NAME, &fops); 00495 if (dev_major < 0) { 00496 rsbac_printk(KERN_WARNING "dazuko: unable to register any major chrdev, err=%d\n", 00497 dev_major); 00498 return dev_major; 00499 } 00500 dazuko_class = class_create(THIS_MODULE, "dazuko"); 00501 class_device_create(dazuko_class, NULL, 00502 MKDEV(dev_major, 0), 00503 NULL, "dazuko"); 00504 } 00505 return 0; 00506 #else 00507 #ifdef CONFIG_DEVFS_FS 00508 dev_major = devfs_register_chrdev(wanted_major, DEVICE_NAME, &fops); 00509 00510 if (wanted_major && !dev_major) 00511 dev_major = wanted_major; 00512 00513 if (dev_major > 0) 00514 devfs_register(NULL, DEVICE_NAME, DEVFS_FL_DEFAULT, 00515 dev_major, 0, S_IFCHR | S_IRUSR | S_IWUSR, 00516 &fops, NULL); 00517 #else 00518 dev_major = register_chrdev(wanted_major, DEVICE_NAME, &fops); 00519 #endif 00520 if (dev_major <= 0) 00521 { 00522 rsbac_printk(KERN_WARNING "dazuko: unable to register device chrdev, err=%d\n", dev_major); 00523 return dev_major; 00524 } 00525 00526 /* initialization complete */ 00527 00528 return 0; 00529 #endif 00530 }
int xp_sys_unhook | ( | void | ) | [inline] |
Definition at line 532 of file daz_main.c.
References dazuko_class, dev_major, DEVICE_NAME, NULL, rsbac_printk(), and xp_print().
00533 { 00534 /* Called by rmmod when removing the module. */ 00535 int error; 00536 00537 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 00538 error = unregister_chrdev(dev_major, DEVICE_NAME); 00539 class_device_destroy(dazuko_class, 00540 MKDEV(dev_major, CONFIG_RSBAC_DAZ_DEV_MAJOR)); 00541 class_destroy(dazuko_class); 00542 #else 00543 #ifdef CONFIG_DEVFS_FS 00544 error = devfs_unregister_chrdev(dev_major, DEVICE_NAME); 00545 devfs_unregister(devfs_find_handle(NULL, DEVICE_NAME, dev_major, 0, DEVFS_SPECIAL_CHR, 0)); 00546 #else 00547 error = unregister_chrdev(dev_major, DEVICE_NAME); 00548 #endif 00549 #endif 00550 if (error < 0) 00551 { 00552 rsbac_printk(KERN_WARNING "dazuko: error unregistering chrdev, err=%d\n", error); 00553 } 00554 00555 return 0; 00556 }
int xp_up | ( | struct xp_mutex * | mutex | ) | [inline] |
Definition at line 164 of file daz_main.c.
References xp_mutex::mutex.
00165 { 00166 up(&(mutex->mutex)); 00167 return 0; 00168 }
int xp_verify_user_readable | ( | const void * | user_ptr, | |
size_t | size | |||
) | [inline] |
int xp_verify_user_writable | ( | const void * | user_ptr, | |
size_t | size | |||
) | [inline] |
int xp_wait_until_condition | ( | struct xp_queue * | queue, | |
int(*)(void *) | cfunction, | |||
void * | cparam, | |||
int | allow_interrupt | |||
) | [inline] |
Definition at line 222 of file daz_main.c.
References xp_queue::queue, wait_event, and wait_event_interruptible.
00223 { 00224 /* wait until cfunction(cparam) != 0 (condition is true) */ 00225 00226 if (allow_interrupt) 00227 { 00228 return wait_event_interruptible(queue->queue, cfunction(cparam) != 0); 00229 } 00230 else 00231 { 00232 wait_event(queue->queue, cfunction(cparam) != 0); 00233 } 00234 00235 return 0; 00236 }
int xp_write_lock | ( | struct xp_rwlock * | rwlock | ) | [inline] |
Definition at line 184 of file daz_main.c.
References xp_rwlock::rwlock.
00185 { 00186 write_lock(&(rwlock->rwlock)); 00187 return 0; 00188 }
int xp_write_unlock | ( | struct xp_rwlock * | rwlock | ) | [inline] |
Definition at line 190 of file daz_main.c.
References xp_rwlock::rwlock.
00191 { 00192 write_unlock(&(rwlock->rwlock)); 00193 return 0; 00194 }