--- zzzz-none-000/linux-4.1.38/kernel/module.c 2017-01-18 18:48:06.000000000 +0000 +++ bcm63-7582-715/linux-4.1.38/kernel/module.c 2020-11-25 10:06:48.000000000 +0000 @@ -61,6 +61,12 @@ #include #include #include "module-internal.h" +#if defined(CONFIG_AVM_FASTIRQ) +#include +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ +#if defined(CONFIG_BUG_EXTRA_INFO) +#include +#endif/*--- #if defined(CONFIG_BUG_EXTRA_INFO) ---*/ #define CREATE_TRACE_POINTS #include @@ -538,7 +544,11 @@ { struct module *mod; unsigned int cpu; - +#if defined(CONFIG_AVM_FASTIRQ) + if(firq_is_avm_rte_restricted_mem_access()) { + return false; + } +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ preempt_disable(); list_for_each_entry_rcu(mod, &modules, list) { @@ -2402,14 +2412,24 @@ ddebug_remove_module(debug->modname); } +#if !defined(CONFIG_AVM_ENHANCED) void * __weak module_alloc(unsigned long size) { return vmalloc_exec(size); } +#endif/*--- #if !defined(CONFIG_AVM_ENHANCED) ---*/ -static void *module_alloc_update_bounds(unsigned long size) -{ - void *ret = module_alloc(size); +static void *module_alloc_update_bounds(unsigned long size +#if defined(CONFIG_AVM_ENHANCED) + , char *name, enum _module_alloc_type_ type +#endif/*--- #if defined(CONFIG_AVM_ENHANCED) ---*/ + ) +{ + void *ret = module_alloc(size +#if defined(CONFIG_AVM_ENHANCED) + , name , type +#endif/*--- #if defined(CONFIG_AVM_ENHANCED) ---*/ + ); if (ret) { mutex_lock(&module_mutex); @@ -2833,7 +2853,11 @@ void *ptr; /* Do the allocs. */ - ptr = module_alloc_update_bounds(mod->core_size); + ptr = module_alloc_update_bounds(mod->core_size +#if defined(CONFIG_AVM_ENHANCED) + , mod->name , module_alloc_type_core +#endif/*--- #if defined(CONFIG_AVM_ENHANCED) ---*/ + ); /* * The pointer to this block is stored in the module structure * which is inside the block. Just mark it as not being a @@ -2847,7 +2871,11 @@ mod->module_core = ptr; if (mod->init_size) { - ptr = module_alloc_update_bounds(mod->init_size); + ptr = module_alloc_update_bounds(mod->init_size +#if defined(CONFIG_AVM_ENHANCED) + , mod->name , module_alloc_type_init +#endif/*--- #if defined(CONFIG_AVM_ENHANCED) ---*/ + ); /* * The pointer to this block is stored in the module structure * which is inside the block. This block doesn't need to be @@ -3553,14 +3581,20 @@ struct module *mod; const char *ret = NULL; +#if defined(CONFIG_AVM_FASTIRQ) + if(firq_is_avm_rte_restricted_mem_access()) { + return NULL; + } +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ + preempt_disable(); list_for_each_entry_rcu(mod, &modules, list) { if (mod->state == MODULE_STATE_UNFORMED) continue; if (within_module(addr, mod)) { - if (modname) - *modname = mod->name; - ret = get_ksymbol(mod, addr, size, offset); + if (modname) + *modname = mod->name; + ret = get_ksymbol(mod, addr, size, offset); break; } } @@ -3577,6 +3611,12 @@ { struct module *mod; +#if defined(CONFIG_AVM_FASTIRQ) + if(firq_is_avm_rte_restricted_mem_access()) { + return -ERANGE; + } +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ + preempt_disable(); list_for_each_entry_rcu(mod, &modules, list) { if (mod->state == MODULE_STATE_UNFORMED) @@ -3601,6 +3641,11 @@ unsigned long *offset, char *modname, char *name) { struct module *mod; +#if defined(CONFIG_AVM_FASTIRQ) + if(firq_is_avm_rte_restricted_mem_access()) { + return -ERANGE; + } +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ preempt_disable(); list_for_each_entry_rcu(mod, &modules, list) { @@ -3630,6 +3675,12 @@ { struct module *mod; +#if defined(CONFIG_AVM_FASTIRQ) + if(firq_is_avm_rte_restricted_mem_access()) { + return -ERANGE; + } +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ + preempt_disable(); list_for_each_entry_rcu(mod, &modules, list) { struct mod_kallsyms *kallsyms; @@ -3671,6 +3722,11 @@ char *colon; unsigned long ret = 0; +#if defined(CONFIG_AVM_FASTIRQ) + if(firq_is_avm_rte_restricted_mem_access()) { + return ret; + } +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ /* Don't lock: we're in enough trouble already. */ preempt_disable(); if ((colon = strchr(name, ':')) != NULL) { @@ -3775,6 +3831,7 @@ /* Used by oprofile and other similar tools. */ seq_printf(m, " 0x%pK", mod->module_core); + /* Taints info */ if (mod->taints) seq_printf(m, " %s", module_flags(mod, buf)); @@ -3820,6 +3877,11 @@ { const struct exception_table_entry *e = NULL; struct module *mod; +#if defined(CONFIG_AVM_FASTIRQ) + if(firq_is_avm_rte_restricted_mem_access()) { + return e; + } +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ preempt_disable(); list_for_each_entry_rcu(mod, &modules, list) { @@ -3852,6 +3914,11 @@ { bool ret; +#if defined(CONFIG_AVM_FASTIRQ) + if(firq_is_avm_rte_restricted_mem_access()) { + return false; + } +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ preempt_disable(); ret = __module_address(addr) != NULL; preempt_enable(); @@ -3877,7 +3944,7 @@ if (mod->state == MODULE_STATE_UNFORMED) continue; if (within_module(addr, mod)) - return mod; + return mod; } return NULL; } @@ -3894,7 +3961,11 @@ bool is_module_text_address(unsigned long addr) { bool ret; - +#if defined(CONFIG_AVM_FASTIRQ) + if(firq_is_avm_rte_restricted_mem_access()) { + return false; + } +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ preempt_disable(); ret = __module_text_address(addr) != NULL; preempt_enable(); @@ -3928,6 +3999,12 @@ struct module *mod; char buf[8]; +#if defined(CONFIG_AVM_FASTIRQ) + if(firq_is_avm_rte_restricted_mem_access()) { + return; + } +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ + printk(KERN_DEFAULT "Modules linked in:"); /* Most callers should already have preempt disabled, but make sure */ preempt_disable(); @@ -3935,6 +4012,15 @@ if (mod->state == MODULE_STATE_UNFORMED) continue; pr_cont(" %s%s", mod->name, module_flags(mod, buf)); +#if !defined(CONFIG_AVM_ENHANCED) && defined(CONFIG_BCM_KF_EXTRA_DEBUG) + { + printk(" init_addr(%p - %p), core_addr(%p - %p)\n", + mod->module_init, + mod->module_init+mod->init_text_size, + mod->module_core, + mod->module_core+mod->core_text_size); + } +#endif } preempt_enable(); if (last_unloaded_module[0])