diff --git a/src/modules/self-defense/hiding/p_hiding.c b/src/modules/self-defense/hiding/p_hiding.c index 53882ce..b74995e 100644 --- a/src/modules/self-defense/hiding/p_hiding.c +++ b/src/modules/self-defense/hiding/p_hiding.c @@ -42,6 +42,10 @@ void p_hide_itself(void) { p_find_sect_attrs = p_find_me->sect_attrs; p_find_notes_attrs = p_find_me->notes_attrs; */ + p_text_section_lock(); + /* We are heavily consuming module list here - take 'module_mutex' */ + mutex_lock(&module_mutex); + spin_lock(&p_db_lock); P_HIDE_FROM_MODULE_LIST(p_find_me); P_HIDE_FROM_KOBJ(p_find_me); @@ -49,8 +53,26 @@ void p_hide_itself(void) { P_HIDE_FROM_DDEBUG(p_find_me); #endif + /* OK, now recalculate hashes again! */ + while(p_kmod_hash(&p_db.p_module_list_nr,&p_db.p_module_list_array, + &p_db.p_module_kobj_nr,&p_db.p_module_kobj_array, 0x2) != P_LKRG_SUCCESS) + schedule(); + + /* Update global module list/kobj hash */ + p_db.p_module_list_hash = p_lkrg_fast_hash((unsigned char *)p_db.p_module_list_array, + (unsigned int)p_db.p_module_list_nr * sizeof(p_module_list_mem)); + + p_db.p_module_kobj_hash = p_lkrg_fast_hash((unsigned char *)p_db.p_module_kobj_array, + (unsigned int)p_db.p_module_kobj_nr * sizeof(p_module_kobj_mem)); + /* We should be fine now! */ + p_lkrg_global_ctrl.p_hide_module = 0x1; + spin_unlock(&p_db_lock); + /* Release the 'module_mutex' */ + mutex_unlock(&module_mutex); + p_text_section_unlock(); + p_hide_itself_out: // STRONG_DEBUG @@ -78,14 +100,37 @@ void p_unhide_itself(void) { goto p_unhide_itself_out; } + p_text_section_lock(); + /* We are heavily consuming module list here - take 'module_mutex' */ + mutex_lock(&module_mutex); + spin_lock(&p_db_lock); + P_UNHIDE_FROM_MODULE_LIST(p_find_me,p_global_modules); P_UNHIDE_FROM_KOBJ(p_find_me,p_tmp_kset,p_tmp_ktype); // P_UNHIDE_FROM_KOBJ(p_find_me,p_find_kobj_parent, // p_find_sect_attrs,p_find_notes_attrs); + /* OK, now recalculate hashes again! */ + while(p_kmod_hash(&p_db.p_module_list_nr,&p_db.p_module_list_array, + &p_db.p_module_kobj_nr,&p_db.p_module_kobj_array, 0x2) != P_LKRG_SUCCESS) + schedule(); + + /* Update global module list/kobj hash */ + p_db.p_module_list_hash = p_lkrg_fast_hash((unsigned char *)p_db.p_module_list_array, + (unsigned int)p_db.p_module_list_nr * sizeof(p_module_list_mem)); + + p_db.p_module_kobj_hash = p_lkrg_fast_hash((unsigned char *)p_db.p_module_kobj_array, + (unsigned int)p_db.p_module_kobj_nr * sizeof(p_module_kobj_mem)); + /* We should be fine now! */ + p_lkrg_global_ctrl.p_hide_module = 0x0; + spin_unlock(&p_db_lock); + /* Release the 'module_mutex' */ + mutex_unlock(&module_mutex); + p_text_section_unlock(); + p_unhide_itself_out: // STRONG_DEBUG