kmodloader: log error message in case of out of memory Log "out of memory" error message in case of OOM Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
kmodloader: lift restriction on module alias info kmodloader has a restriction of storing only 32 aliases for a given module; as modules can have easily more than 32 aliases let's remove the restriction by using a dynamic allocation mechanism when retrieving the aliases. While at it also check the get_module_info return value setting an error code in case NULL is returned. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
kmodloader: fix possible segfaults Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
kmodloader: fix endianess check Use __BYTE_ORDER macro to check system endianess as the macro's __LITTLE_ENDIAN, __BIG_ENDIAN are defined irrespective of the sytem endianess leading to an endianess check failure on big endian systems. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com> Acked-by: John Crispin <john@phrozen.org>
kmodloader: Check module endian before loading If we manage to accidentally get a module installed that does not match the system endianess (there is currently nothing preventing that in OpenWrt/LEDE) we will hit a segmentation fault when doing this: sh = (Elf32_Shdr *) (map + e->e_shoff); because e->e_shoff will be wrongly encoded and this most likely will result in an invalid offset to de-reference from. Update elf_find_section() to check that the build time endianess of kmodloader matches that of the module, otherwise nothing would work really. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
kmodloader/get_module_info: initialized aliases to make it more clean Even when the callee looks onto the length is a good idea to zero the points. Found-by: Coverity Scan #1412541 Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
kmodloader: insmod: fix a memoryleak in error case Found-by: Coverity Scan #1412469 Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
kmodloader/get_module_name: null-terminate the string Found-by: Coverity Scan #1412291 Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
kmodloader: modprobe: return 0 for loaded modules This is the default behaviour with modprobe from kmod package [1] unless it is explicitly told that the module is to be loaded for --first-time [1] http://www.kernel.org/pub/linux/utils/kernel/kmod/ Fixes FS#433 Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
kmodloader: don't store aliases info in struct module This also fixes FS#544 as the possible address alignment issue should now disappear function old new delta alloc_module 398 245 -153 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-153) Total: -153 bytes Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
kmodloader: fix not being able to find some modules kmodloader is using slightly different criteria for ordering the AVL tree versus what it uses to traverse it. This sometimes results in not being able to find some modules. Reference: https://bugs.lede-project.org/index.php?do=details&task_id=443 Signed-off-by: Nathan Hintz <nlhintz@hotmail.com>
kmodloader: support '-q' quiet option The kernel opportunistically attempts to load modules in advanced with 'predicted' module names. Often these modules don't exist and hence kmodloader produces lots of logfile noise. The kernel commandline to modprobe from kworker proceses is '-q -- modulename' where '-q' means quiet. Support suppressing that noise. Signed-off-by: Kevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk>
kmodloader: make insert_module() idempotent To fix spurious error messages in the following situation 1. scan loaded modules 2. load wireguard.ko and the module itself will request xt_hashlimit to be loaded 3. xt_hashlimit is still in PROBE state here so we also try to load it, but init_module() returns EEXIST Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
kmodloader: add module alias awareness To achieve this, the following changes are made - scan module folders before scaning loaded modules - struct module was splited into struct module_node for the avl tree and struct module for storing actual info about modules The other minor fix is that module.opts is now freed in free_modules() when appliable Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
kmodloader: fix out-of-bound access when parsing .modinfo Fixes output of "modinfo nf_conntrack_ipv4" module: /lib/modules/4.4.40/nf_conntrack_ipv4.ko license: GPL alias: ip_conntrack alias: nf_conntrack-2 depends: nf_conntrack,nf_defrag_ipv4 src: %pI4 dst=%pI4 Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
kmodloader: modprobe: skip possible command line arguments The kernel may invocate user mode modprobe with the following scheme modprobe -q -- <module_name> Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
kmodloader: log to kmsg when loading directories of modules syslog may not be ready yet before PREINIT Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
kmodloader: remove redundant glob wildcard char Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
ubox: Fix some memory leaks Avoids leaking memory when exiting early. Signed-off by: Rosen <rosenp@gmail.com>
kmodloader: Fix typo in error message Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>