diff -urN lkrg-0.7_orig/src/modules/self-defense/hiding/p_hiding.c lkrg-0.7_alt/src/modules/self-defense/hiding/p_hiding.c --- lkrg-0.7_orig/src/modules/self-defense/hiding/p_hiding.c 2019-06-18 20:47:26.000000000 +0300 +++ lkrg-0.7_alt/src/modules/self-defense/hiding/p_hiding.c 2019-09-17 19:49:34.958257713 +0300 @@ -43,14 +43,20 @@ p_find_notes_attrs = p_find_me->notes_attrs; */ + P_HIDE_LOCK; + P_HIDE_FROM_MODULE_LIST(p_find_me); P_HIDE_FROM_KOBJ(p_find_me); #if defined(CONFIG_DYNAMIC_DEBUG) P_HIDE_FROM_DDEBUG(p_find_me); #endif + P_HIDE_RECALC; + p_lkrg_global_ctrl.p_hide_module = 0x1; + P_HIDE_UNLOCK; + p_hide_itself_out: // STRONG_DEBUG @@ -78,14 +84,20 @@ goto p_unhide_itself_out; } + P_HIDE_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); + P_HIDE_RECALC; + p_lkrg_global_ctrl.p_hide_module = 0x0; + P_HIDE_UNLOCK; + p_unhide_itself_out: // STRONG_DEBUG diff -urN lkrg-0.7_orig/src/modules/self-defense/hiding/p_hiding.h lkrg-0.7_alt/src/modules/self-defense/hiding/p_hiding.h --- lkrg-0.7_orig/src/modules/self-defense/hiding/p_hiding.h 2019-06-18 20:47:26.000000000 +0300 +++ lkrg-0.7_alt/src/modules/self-defense/hiding/p_hiding.h 2019-09-17 19:46:21.842349857 +0300 @@ -135,6 +135,30 @@ */ #endif +#define P_HIDE_LOCK \ + p_text_section_lock(); \ + /* We are heavily consuming module list here - take 'module_mutex' */ \ + mutex_lock(&module_mutex); \ + spin_lock(&p_db_lock); \ + +#define P_HIDE_UNLOCK \ + spin_unlock(&p_db_lock); \ + /* Release the 'module_mutex' */ \ + mutex_unlock(&module_mutex); \ + p_text_section_unlock(); + +#define P_HIDE_RECALC \ + /* 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! */ + extern struct module *p_find_me;