#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/fs.h>
#include <rsbac/types.h>
#include <rsbac/reg.h>
#include <rsbac/adf.h>
#include <rsbac/aci.h>
#include <rsbac/getname.h>
#include <rsbac/error.h>
#include <rsbac/proc_fs.h>
Go to the source code of this file.
void cleanup_module | ( | void | ) |
Definition at line 303 of file reg_sample1.c.
References handle, proc_rsbac_root_p, rsbac_printk(), rsbac_reg_unregister(), rsbac_reg_unregister_syscall(), and syscall_registration_handle.
00304 { 00305 rsbac_printk(KERN_INFO "RSBAC REG decision module sample 1: Unregistering.\n"); 00306 #if defined(CONFIG_RSBAC_PROC) 00307 remove_proc_entry(PROC_NAME, proc_rsbac_root_p); 00308 #endif 00309 if(rsbac_reg_unregister_syscall(syscall_registration_handle)) 00310 { 00311 rsbac_printk(KERN_ERR "RSBAC REG decision module sample 1: Unregistering syscall failed - beware of possible system failure!\n"); 00312 } 00313 if(rsbac_reg_unregister(handle)) 00314 { 00315 rsbac_printk(KERN_ERR "RSBAC REG decision module sample 1: Unregistering failed - beware of possible system failure!\n"); 00316 } 00317 rsbac_printk(KERN_INFO "RSBAC REG decision module sample 1: Unloaded.\n"); 00318 }
int init_module | ( | void | ) |
Definition at line 206 of file reg_sample1.c.
References dummy_buf, dummy_buf2, handle, name, need_overwrite_func(), proc_rsbac_root_p, request_func(), rsbac_printk(), RSBAC_REG_NAME_LEN, rsbac_reg_register(), rsbac_reg_register_syscall(), rsbac_reg_unregister(), rsbac_reg_unregister_syscall(), RSBAC_REG_VERSION, set_attr_func(), syscall_dispatcher_handle, syscall_func(), syscall_name, syscall_registration_handle, and TRUE.
00207 { 00208 struct rsbac_reg_entry_t entry; 00209 struct rsbac_reg_syscall_entry_t syscall_entry; 00210 00211 if(!handle) 00212 handle = 123456; 00213 if(!syscall_registration_handle) 00214 syscall_registration_handle = 654321; 00215 if(!syscall_dispatcher_handle) 00216 syscall_dispatcher_handle = 1; 00217 00218 rsbac_printk(KERN_INFO "RSBAC REG decision module sample 1: Initializing.\n"); 00219 00220 /* clearing registration entries */ 00221 memset(&entry, 0, sizeof(entry)); 00222 memset(&syscall_entry, 0, sizeof(syscall_entry)); 00223 00224 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,0) 00225 if((dummy_buf[0] != 'T') || (dummy_buf2[0] != 'T')) 00226 { 00227 rsbac_printk(KERN_WARNING "RSBAC REG decision module sample 1: Not loaded due to invalid param string.\n"); 00228 return -ENOEXEC; 00229 } 00230 #endif 00231 if(name) 00232 { 00233 strncpy(entry.name, name, RSBAC_REG_NAME_LEN); 00234 entry.name[RSBAC_REG_NAME_LEN] = 0; 00235 } 00236 else 00237 strcpy(entry.name, "RSBAC REG sample 1 ADF module"); 00238 rsbac_printk(KERN_INFO "RSBAC REG decision module sample 1: REG Version: %u, Name: %s, Handle: %li\n", 00239 RSBAC_REG_VERSION, entry.name, handle); 00240 00241 entry.handle = handle; 00242 entry.request_func = request_func; 00243 entry.set_attr_func = set_attr_func; 00244 entry.need_overwrite_func = need_overwrite_func; 00245 entry.switch_on = TRUE; 00246 rsbac_printk(KERN_INFO "RSBAC REG decision module sample 1: Registering to ADF.\n"); 00247 if(rsbac_reg_register(RSBAC_REG_VERSION, entry) < 0) 00248 { 00249 rsbac_printk(KERN_WARNING "RSBAC REG decision module sample 1: Registering failed. Unloading.\n"); 00250 return -ENOEXEC; 00251 } 00252 00253 if(syscall_name) 00254 { 00255 strncpy(syscall_entry.name, syscall_name, RSBAC_REG_NAME_LEN); 00256 syscall_entry.name[RSBAC_REG_NAME_LEN] = 0; 00257 } 00258 else 00259 strcpy(syscall_entry.name, "RSBAC REG sample 1 syscall"); 00260 rsbac_printk(KERN_INFO "RSBAC REG decision module sample 1: REG Version: %u, Name: %s, Dispatcher Handle: %li\n", 00261 RSBAC_REG_VERSION, syscall_entry.name, syscall_dispatcher_handle); 00262 00263 syscall_entry.registration_handle = syscall_registration_handle; 00264 syscall_entry.dispatcher_handle = syscall_dispatcher_handle; 00265 syscall_entry.syscall_func = syscall_func; 00266 rsbac_printk(KERN_INFO "RSBAC REG decision module sample 1: Registering syscall.\n"); 00267 syscall_registration_handle = rsbac_reg_register_syscall(RSBAC_REG_VERSION, syscall_entry); 00268 if(syscall_registration_handle < 0) 00269 { 00270 rsbac_printk(KERN_WARNING "RSBAC REG decision module sample 1: Registering syscall failed. Unloading.\n"); 00271 if(rsbac_reg_unregister(handle)) 00272 { 00273 rsbac_printk(KERN_ERR "RSBAC REG decision module sample 1: Unregistering failed - beware of possible system failure!\n"); 00274 } 00275 return -ENOEXEC; 00276 } 00277 00278 #if defined(CONFIG_RSBAC_PROC) 00279 proc_reg_sample_p = create_proc_entry(PROC_NAME, 00280 S_IFREG | S_IRUGO, 00281 proc_rsbac_root_p); 00282 if(!proc_reg_sample_p) 00283 { 00284 rsbac_printk(KERN_WARNING "%s: Not loaded due to failed proc entry registering.\n", name); 00285 if(rsbac_reg_unregister(handle)) 00286 { 00287 rsbac_printk(KERN_ERR "RSBAC REG decision module sample 1: Unregistering failed - beware of possible system failure!\n"); 00288 } 00289 if(rsbac_reg_unregister_syscall(syscall_registration_handle)) 00290 { 00291 rsbac_printk(KERN_ERR "RSBAC REG decision module sample 1: Unregistering syscall failed - beware of possible system failure!\n"); 00292 } 00293 return -ENOEXEC; 00294 } 00295 proc_reg_sample_p->get_info = adf_sample_proc_info; 00296 #endif 00297 00298 rsbac_printk(KERN_INFO "RSBAC REG decision module sample 1: Loaded.\n"); 00299 00300 return 0; 00301 }
MODULE_AUTHOR | ( | "Amon Ott" | ) |
MODULE_DESCRIPTION | ( | "RSBAC REG sample decision module 1" | ) |
MODULE_LICENSE | ( | "GPL" | ) |
module_param | ( | syscall_dispatcher_handle | , | |
long | , | |||
S_IRUSR | ||||
) |
module_param | ( | syscall_registration_handle | , | |
long | , | |||
S_IRUSR | ||||
) |
module_param | ( | handle | , | |
long | , | |||
S_IRUSR | ||||
) |
module_param | ( | syscall_name | , | |
charp | , | |||
0000 | ||||
) |
module_param | ( | name | , | |
charp | , | |||
0000 | ||||
) |
MODULE_PARM_DESC | ( | syscall_dispatcher_handle | , | |
"Syscall dispatcher" | ||||
) |
MODULE_PARM_DESC | ( | syscall_registration_handle | , | |
"Syscall registration handle" | ||||
) |
MODULE_PARM_DESC | ( | handle | , | |
"Handle" | ||||
) |
MODULE_PARM_DESC | ( | syscall_name | , | |
"Syscall name" | ||||
) |
MODULE_PARM_DESC | ( | name | , | |
"Name" | ||||
) |
static rsbac_boolean_t need_overwrite_func | ( | struct dentry * | dentry_p | ) | [static] |
Definition at line 191 of file reg_sample1.c.
References FALSE, and nr_need_overwrite_calls.
Referenced by init_module().
00192 { 00193 nr_need_overwrite_calls++; 00194 return FALSE; 00195 }
static int request_func | ( | enum rsbac_adf_request_t | request, | |
rsbac_pid_t | owner_pid, | |||
enum rsbac_target_t | target, | |||
union rsbac_target_id_t | tid, | |||
enum rsbac_attribute_t | attr, | |||
union rsbac_attribute_value_t | attr_val, | |||
rsbac_uid_t | owner | |||
) | [static] |
Definition at line 161 of file reg_sample1.c.
References GRANTED, nr_request_calls, and R_SEARCH.
00168 { 00169 /* count call, but not for SEARCH request */ 00170 if(request != R_SEARCH) 00171 nr_request_calls++; 00172 return GRANTED; 00173 }
static int set_attr_func | ( | enum rsbac_adf_request_t | request, | |
rsbac_pid_t | owner_pid, | |||
enum rsbac_target_t | target, | |||
union rsbac_target_id_t | tid, | |||
enum rsbac_target_t | new_target, | |||
union rsbac_target_id_t | new_tid, | |||
enum rsbac_attribute_t | attr, | |||
union rsbac_attribute_value_t | attr_val, | |||
rsbac_uid_t | owner | |||
) | [static] |
Definition at line 175 of file reg_sample1.c.
References nr_set_attr_calls, and R_SEARCH.
Referenced by init_module().
00184 { 00185 /* count call, but not for SEARCH request */ 00186 if(request != R_SEARCH) 00187 nr_set_attr_calls++; 00188 return 0; 00189 }
static int syscall_func | ( | void * | arg | ) | [static] |
Definition at line 197 of file reg_sample1.c.
References nr_system_calls, and system_call_arg.
Referenced by init_module().
00198 { 00199 nr_system_calls++; 00200 system_call_arg = arg; 00201 return nr_system_calls; 00202 }
long handle = 123456 [static] |
Definition at line 33 of file reg_sample1.c.
char* name = NULL [static] |
Definition at line 31 of file reg_sample1.c.
Referenced by acl_detach_fd_lists(), acl_register_fd_lists(), get_attribute_value_name(), get_target_name(), group_name_compare(), init_module(), name_compare(), read_info(), read_list(), read_lol_list(), register_fd_lists(), rsbac_init_rc(), and write_info().
u_long nr_need_overwrite_calls = 0 [static] |
Definition at line 22 of file reg_sample1.c.
Referenced by init_module(), need_overwrite_func(), read_info(), and write_info().
u_long nr_request_calls = 0 [static] |
Definition at line 20 of file reg_sample1.c.
Referenced by init_module(), read_info(), request_func(), and write_info().
u_long nr_set_attr_calls = 0 [static] |
Definition at line 21 of file reg_sample1.c.
Referenced by init_module(), read_info(), set_attr_func(), and write_info().
u_long nr_system_calls = 0 [static] |
long syscall_dispatcher_handle = 1 [static] |
char* syscall_name = NULL [static] |
long syscall_registration_handle = 654321 [static] |
void* system_call_arg = NULL [static] |