kproc_hide.c

Go to the documentation of this file.
00001 /*
00002  * RSBAC REG decision module kproc_hide. Hiding kernel processes.
00003  *
00004  * Author and (c) 2004 Michal Purzynski <albeiro@polsl.gliwice.pl>
00005  */
00006 
00007 #include <linux/config.h>
00008 #include <linux/module.h>
00009 #include <linux/types.h>
00010 #include <linux/kernel.h>
00011 #include <linux/string.h>
00012 #include <linux/fs.h>
00013 #include <linux/sched.h>
00014 #include <linux/file.h>
00015 #include <rsbac/types.h>
00016 #include <rsbac/reg.h>
00017 #include <rsbac/adf.h>
00018 #include <rsbac/aci.h>
00019 #include <rsbac/getname.h>
00020 #include <rsbac/error.h>
00021 #include <rsbac/proc_fs.h>
00022 
00023 MODULE_AUTHOR("Michal Purzynski");
00024 MODULE_DESCRIPTION("RSBAC REG kproc_hide decision module");
00025 MODULE_LICENSE("GPL");
00026 
00027 static long handle = 9999992;
00028 
00029 /**** Helper Functions ****/
00030 
00031 /**********************************************************************
00032 Description:  Checks if process is a kernel process.
00033 Parameters:   Pid of checking process.
00034 Return value: 1 if is, 0 otherwise.
00035 **********************************************************************/
00036 
00037 int is_kproc(int pid)
00038 {
00039         struct task_struct *tid_task;
00040 
00041         tid_task = find_task_by_pid(pid);
00042 
00043         if (tid_task->mm == NULL)
00044                 return 1;
00045         else
00046                 return 0;
00047 }
00048 
00049 /**** Decision Functions ****/
00050 
00051 static int request_func(enum rsbac_adf_request_t        request,
00052                         rsbac_pid_t                     owner_pid,
00053                         enum rsbac_target_t             target,
00054                         union rsbac_target_id_t         tid,
00055                         enum rsbac_attribute_t          attr,
00056                         union rsbac_attribute_value_t   attr_val,
00057                         rsbac_uid_t                     owner)
00058 {  
00059 
00060         switch (request) {
00061                 case R_GET_STATUS_DATA:
00062                         switch (target) {
00063                                 case T_PROCESS:
00064                                         if (is_kproc(tid.process))
00065                                         return NOT_GRANTED;
00066                                 default:
00067                                         return DO_NOT_CARE;
00068                         }
00069                 default:
00070                         return DO_NOT_CARE;
00071         }
00072         
00073 /*
00074         if (request == R_GET_STATUS_DATA && target == T_PROCESS && is_kproc(tid.process))
00075                 return NOT_GRANTED;
00076         else
00077                 return GRANTED;
00078 */
00079 }
00080 
00081 /**** Init ****/
00082 
00083 int init_module(void)
00084 {
00085         struct rsbac_reg_entry_t entry;
00086 
00087         printk(KERN_INFO "RSBAC REG decision module kproc_hide: Initializing.\n");
00088 
00089         /* clearing registration entries */
00090         memset(&entry, 0, sizeof(entry));
00091 
00092         strcpy(entry.name, "RSBAC REG kproc_hide ADF module");
00093         printk(KERN_INFO "RSBAC REG decision module kproc_hide: REG Version: %u, Name: %s, Handle: %li\n",
00094                                                                 RSBAC_REG_VERSION, entry.name, handle);
00095 
00096         entry.handle = handle;
00097         entry.request_func = request_func;
00098         entry.switch_on = TRUE;
00099         printk(KERN_INFO "RSBAC REG decision module kproc_hide: Registering to ADF.\n");
00100         
00101         if(rsbac_reg_register(RSBAC_REG_VERSION, entry) < 0) {
00102                 printk(KERN_WARNING "RSBAC REG decision module sample 1: Registering failed. Unloading.\n");
00103                 return -ENOEXEC;
00104         }
00105 
00106         printk(KERN_INFO "RSBAC REG decision module kproc_hide: Loaded.\n");
00107 
00108         return 0;
00109 }
00110 
00111 void cleanup_module(void)
00112 {
00113         printk(KERN_INFO "RSBAC REG decision module kproc_hide: Unregistering.\n");
00114         
00115         if(rsbac_reg_unregister(handle))
00116         {
00117                 printk(KERN_ERR "RSBAC REG decision module kproc_hide: Unregistering failed \
00118                                                 - beware of possible system failure!\n");
00119         }
00120         
00121         printk(KERN_INFO "RSBAC REG decision module kproc_hide: Unloaded.\n");
00122 }
00123 

Generated on Fri Jun 17 09:45:20 2005 for RSBAC by  doxygen 1.4.2