Christian Marangi [Sat, 2 Mar 2024 16:11:42 +0000 (17:11 +0100)]
CI: add build test for ubox
Add build test for ubox. Use alpine container and install libubox,
libubus, libudebug, ucode and libuci as dependency.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Christian Marangi [Sat, 2 Mar 2024 16:10:55 +0000 (17:10 +0100)]
.gitignore: don't ignore .github directory
Don't ignore .github special directory as it does contain specific files
for github CI workflows.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Tony Ambardar [Mon, 22 Jan 2024 08:48:37 +0000 (00:48 -0800)]
kmodloader: fix invalid read outside mapped region
Code parsing .modinfo data skips over null sequences without checking
bounds and may read past mapped memory, potentially triggering SIGSEGV.
Fixes: https://github.com/openwrt/openwrt/issues/14463
Fixes: d6e6825c4697 ("add support for module handling")
Refer:
9371411715c8 ("kmodloader: fix out-of-bound access when parsing .modinfo")
Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
Christian Marangi [Mon, 22 Jan 2024 00:13:11 +0000 (01:13 +0100)]
kmodloader: fix TOCTOU problem with scan_builtin_modules
Fix TOCTOU problem with scan_builtin_modules by opening the file pointer
only once in module_folders scan.
Fix Coverity Report CID
1586645: Security best practices violations
(TOCTOU).
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Christian Marangi [Sun, 21 Jan 2024 23:49:44 +0000 (00:49 +0100)]
kmodloader: fix memory leak in print_modinfo
Fix memory leak in print_modinfo reported by Coverity Report.
It seems there is a logic error and duplicated string in print_modinfo
is never freed. On top of this if the while loop terminates early the
just allocated duplicated string is also never freed.
Rework the function to correctly free the duplicated string.
Fix CID
1586644: Resource leaks (RESOURCE_LEAK).
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Christian Marangi [Sun, 21 Jan 2024 23:39:50 +0000 (00:39 +0100)]
kmodloader: Fix NULL pointer dereferences error
Fix NULL pointer dereferences reported by Coverity Scan.
Return early instead of jumping to out and trying to fclose a NULL
pointer.
Fix
- CID
1586642: Null pointer dereferences (FORWARD_NULL)
- CID
1586641: Null pointer dereferences (FORWARD_NULL)
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Tony Ambardar [Tue, 19 Dec 2023 07:15:12 +0000 (23:15 -0800)]
kmodloader: cleanup duplicated mmap() code
Refactor code from get_module_info() and print_modinfo() to locate modinfo
data, call mmap() and handle errors, into new mmap_modinfo(). This drops
~30 source lines and shrinks the compressed binary ~100 bytes.
Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
Tony Ambardar [Thu, 14 Dec 2023 07:18:53 +0000 (23:18 -0800)]
kmodloader: add modinfo support for builtin modules
Enable parsing of 'modules.builtin.modinfo' for better handling of builtin
modules, including support for aliases and showing basic builtin module
details, e.g.
root@OpenWrt:/# modinfo unix
name: unix
filename: (builtin)
alias: net-pf-1
license: GPL
root@OpenWrt:/# modprobe net-pf-1 && echo SUCCESS || echo FAIL
SUCCESS
Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
Tony Ambardar [Thu, 14 Dec 2023 07:18:30 +0000 (23:18 -0800)]
kmodloader: add basic support for builtin modules
Enable parsing of 'modules.builtin' if present, for improved handling of
loadable and builtin modules similar to most other distros. In particular,
this allows 'modprobe' to return success whether a module is loadable or
built-in, a useful feature for consistent presence-testing. For example:
root@OpenWrt:/# rmmod sch_fq_codel
module is builtin
root@OpenWrt:/# modinfo sch_cake
filename: /lib/modules/6.1.65/sch_cake.ko
license: Dual BSD/GPL
depends:
intree: Y
name: sch_cake
vermagic: 6.1.65 SMP mod_unload MIPS32_R2 32BIT
root@OpenWrt:/# modprobe sch_fq_codel && echo SUCCESS || echo FAIL
SUCCESS
root@OpenWrt:/# modprobe sch_cake && echo SUCCESS || echo FAIL
SUCCESS
Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
Tony Ambardar [Fri, 1 Dec 2023 09:40:17 +0000 (01:40 -0800)]
kmodloader: support loadable module parameters in modinfo
Current OpenWrt loadable modules embed details of parameters accepted on
loading, but these aren't shown to users. Enable modinfo to print this
information like most other distros. For example:
root@OpenWrt:/# modinfo mac80211
filename: /lib/modules/6.1.65/mac80211.ko
license: GPL
depends: cfg80211,compat
name: mac80211
vermagic: 6.1.65 SMP mod_unload MIPS32_R2 32BIT
parm: minstrel_vht_only (bool)
parm: max_nullfunc_tries (int)
parm: max_probe_tries (int)
parm: beacon_loss_count (int)
parm: probe_wait_ms (int)
parm: ieee80211_default_rc_algo (charp)
Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
Tony Ambardar [Mon, 15 Jan 2024 20:29:48 +0000 (12:29 -0800)]
kmodloader: fix memory leak in scan_loaded_modules()
Commit
4c7b720b9c63 fixed some error-handling paths but introduced another
memory leak; update and fix.
Fixes: 4c7b720b9c63 ("kmodloader: fix GCC fanalyzer warnings")
Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
Tony Ambardar [Thu, 14 Dec 2023 07:17:24 +0000 (23:17 -0800)]
kmodloader: remove unneeded uname() call
This is not used in scan_modules_folder() so drop.
Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
Felix Fietkau [Thu, 30 Nov 2023 12:42:09 +0000 (13:42 +0100)]
logd: add udebug support
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Thu, 19 Jan 2023 12:06:19 +0000 (13:06 +0100)]
logd: add support for subscribing to the log object
Provides easier access to log messages
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Rosen Penev [Mon, 18 Jul 2022 22:12:38 +0000 (15:12 -0700)]
kmodloader: fix GCC fanalyzer warnings
memory leaks and missing NULL checks.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Rosen Penev [Mon, 18 Jul 2022 22:12:37 +0000 (15:12 -0700)]
kmodloader: fix bad realloc usage
Both cppcheck and gcc's -fanalyzer complain here that realloc is being
used improperly.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Christian Marangi [Sun, 17 Jul 2022 00:59:32 +0000 (02:59 +0200)]
kmodloader: fix compilation warning with not checking return of asprintf
Fix the following compilation warning:
kmodloader.c: In function 'main_loader':
kmodloader.c:1027:41: error: ignoring return value of 'asprintf' declared with attribute 'warn_unused_result' [-Werror=unused-result]
make[1]: *** [package/Makefile:116: package/system/ubox/compile] Error 1
1027 | asprintf(&m->opts, "%s %s", prev, opts);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
While at it rework the function to not duplicate too much code with the
error handling.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Felix Fietkau [Thu, 6 Jan 2022 14:58:11 +0000 (15:58 +0100)]
kmodloader: support loading module options and blacklist from /etc/modules.conf
This has the same format as /etc/modules.d on a regular linux system
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Giovanni Giacobbi [Tue, 27 Jul 2021 13:15:26 +0000 (15:15 +0200)]
logread: fix erroneous message "Logread connected to" with udp
When streaming the syslog messages via udp, the socket connection
always succeeds by definition, but it can still fail to send. In such
case, the syslog keep repeating the following two messages:
failed to send log data to ip:port via udp
Logread connected to ip:port
With this change, only one initial message "Logread connected to..." is
logged.
Also fixed capital letter for "failed to send" message.
Signed-off-by: Giovanni Giacobbi <giovanni@giacobbi.net>
Signed-off-by: Daniel Golle <daniel@makrotopia.org> (string de-duplication)
Giovanni Giacobbi [Tue, 27 Jul 2021 12:39:28 +0000 (14:39 +0200)]
logd: fix privilege dropping order
Fixes: 41664054b8b1 ("logd: fix ignored return values in set{gid,uid}")
Signed-off-by: Giovanni Giacobbi <giovanni@giacobbi.net>
Petr Štetiar [Mon, 22 Mar 2021 17:22:14 +0000 (18:22 +0100)]
logd: fix ignored return values in set{gid,uid}
Ubuntu 18.05 with gcc-7.5 yields following error:
ubox/log/logd.c:263:3: error: ignoring return value of ‘setuid’, declared with attribute warn_unused_result [-Werror=unused-result]
setuid(p->pw_uid);
^~~~~~~~~~~~~~~~~
ubox/log/logd.c:264:3: error: ignoring return value of ‘setgid’, declared with attribute warn_unused_result [-Werror=unused-result]
setgid(p->pw_gid);
^~~~~~~~~~~~~~~~~
Fixes: 9ef886819dd4 ("logd: self-degrade to 'logd' user after opening pipes")
Signed-off-by: Petr Štetiar <ynezz@true.cz>
Daniel Golle [Mon, 19 Oct 2020 15:18:22 +0000 (16:18 +0100)]
logd: self-degrade to 'logd' user after opening pipes
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Gerard Ryan [Tue, 31 Dec 2019 02:01:35 +0000 (12:01 +1000)]
kmodloader: added -a arg to modprobe
-a treats all non-op trailing arguments as module names
and attempts to load all of them. This behaviour mirrors the behaviour
of the respective -a in /tools/modprobe.c from https://git.kernel.org.
This is primarily to satiate the multiple modules passed by
docker/libnetwork.
Signed-off-by: Gerard Ryan <G.M0N3Y.2503@gmail.com>
Paul Fertser [Wed, 18 Dec 2019 16:39:42 +0000 (19:39 +0300)]
kmodloader: print an error when no kernel module dir can be found
Do not just silently fail when kernel modules are nowhere to be
found. This is essential for diagnosing mismatched kernel version
failures.
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Zefir Kurtisi [Thu, 25 Jul 2019 15:43:15 +0000 (17:43 +0200)]
logread: add option to filter for facilities
This adds filtering options for facilities as follows:
-z <facility> handle only messages with given facility (0-23), repeatable
-Z <facility> ignore messages with given facility (0-23), repeatable
With that
* 'logread -z 2 -z 16' will display all MAIL and LOCAL0 messages, while
* 'logread -Z 2 -Z 16' will display all but MAIL and LOCAL0 messages
Signed-off-by: Zefir Kurtisi <zefir.kurtisi@neratec.com>
Gerard Ryan [Sun, 20 Oct 2019 06:01:11 +0000 (16:01 +1000)]
kmodloader: added -v arg to modeprobe
This is primarily to satiate the usage by docker/libnetwork.
Signed-off-by: Gerard Ryan <G.M0N3Y.2503@gmail.com>
Hauke Mehrtens [Sat, 15 Jun 2019 21:49:28 +0000 (23:49 +0200)]
kmodloader: Increase path array size to make it always fit
When DEF_MOD_PATH (10 bytes), s (max 255 bytes) and ver.release (max 64
bytes) are all written into path, 256 bytes will not fit, increase the
available size. All given sizes are given without terminating NULL byte
and we add one byte to store the NULL byte.
GCC 9.1 warns about this condition and we treat warnings as errors in
ubox.
Reported-by: Joseph Benden <joe@benden.us>
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Pavel Merzlyakov [Mon, 18 Mar 2019 10:53:01 +0000 (12:53 +0200)]
kmodloader: fix and optimize loading of failed modules
1) Restore functionality which was lost in commit
876c7f5b.
Again at boot time kmodloader can load all modules (/etc/modules.d/*)
even if dependency information is completely missing.
This functionality is important in case of hidden dependency (not symbol dependency).
For example, in kernel 4.4.60 is hidden dependency between nf_nat_ipv6 and nf_conntrack_ipv6.
We can't load nf_nat_ipv6 before nf_conntrack_ipv6 and modinfo do not show this dependency.
Two sequential load attempts of nf_nat_ipv6 may not be enough (in my case it's definitely not enough).
nf_nat_ipv4 has a similar problem.
2) Reduce count of attempts to load failed modules.
Now kmodloader try to load failed modules after all others are loaded.
main_loader: Count of failed and successful attempts to load nf_nat_ipv6.ko (kernel 4.4.60) depend on ubox version:
COMMIT FAILED SUCCESSFUL TOTAL
128bc35f 53 1 54
876c7f5b 2 0 2
this 1 1 2
Signed-off-by: Pavel Merzlyakov <pavel.merzlyakov@gmail.com>
Acked-by: Jo-Philipp Wich <jo@mein.io>
Sergiy Kibrik [Fri, 22 Feb 2019 06:57:52 +0000 (06:57 +0000)]
kmodloader: increase module name length
Otherwise modules with long names, e.g. lttng (>32 chars) can't be loaded.
Signed-off-by: Sergiy Kibrik <sakib@darkstar.site>
Stijn Tintel [Tue, 18 Dec 2018 19:24:28 +0000 (21:24 +0200)]
kmodloader: load_modprobe: abort after 2 attempts
The loop in load_modprobe causes dmesg to be flooded with errors when a
module fails to load; e.g.:
- gpio-nct5104d: Unsupported device 0xffff (246 times on x86 in Qemu)
- jitterentropy: Initialization failed with host not compliant with
requirements: 2 (229 times on brcm2708/bcm2708)
On brcm2708/bcm2708 this also causes vmalloc allocation failures with
kernel 4.14 when running headless. If kmod-drm-vc4 and
kmod-video-bcm2835 are included in the image, they will be loaded before
brcmfmac, and brcmfmac will fail to load:
kmodloader: vmalloc: allocation failure: 249856 bytes,
mode:0x14000c0(GFP_KERNEL), nodemask=(null)
Break the loop after 2 failed attempts to fix these issues.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
John Crispin [Wed, 14 Feb 2018 08:08:54 +0000 (09:08 +0100)]
logread: fix reconnect logd logic
Signed-off-by: John Crispin <john@phrozen.org>
John Crispin [Wed, 14 Feb 2018 07:47:03 +0000 (08:47 +0100)]
logrea: move the code setting up the request blob out of the main loop
Signed-off-by: John Crispin <john@phrozen.org>
John Crispin [Wed, 14 Feb 2018 07:44:27 +0000 (08:44 +0100)]
logread: move output connection setup code out of main loop
Signed-off-by: John Crispin <john@phrozen.org>
John Crispin [Wed, 14 Feb 2018 07:40:13 +0000 (08:40 +0100)]
logread: cleanup pid file handling
Signed-off-by: John Crispin <john@phrozen.org>
Rosen Penev [Sat, 13 Jan 2018 20:46:04 +0000 (12:46 -0800)]
ubox: Replace strerror(errno) with %m format.
Saves 872 bytes on Ubuntu 16.04. No change in functionality.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Rosen Penev [Tue, 7 Nov 2017 20:22:09 +0000 (12:22 -0800)]
ubox: Remove unnecessary memset calls.
Change to calloc instead. Less verbose.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Felix Fietkau [Mon, 6 Nov 2017 10:48:52 +0000 (11:48 +0100)]
logd: move stripping of newlines to log_add()
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Mon, 6 Nov 2017 10:47:57 +0000 (11:47 +0100)]
logread: fix line buffer size
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Mon, 6 Nov 2017 10:46:24 +0000 (11:46 +0100)]
logread: remove leftover debug code
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Mon, 6 Nov 2017 10:34:31 +0000 (11:34 +0100)]
logd: enforce line length limit for ubus based log messages as well
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Mon, 6 Nov 2017 10:28:33 +0000 (11:28 +0100)]
logread: use oneshot mode without -f, wait for logd to close
Fixes a race condition in dealing with larger amounts of log data
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Mon, 6 Nov 2017 10:27:46 +0000 (11:27 +0100)]
logd: implement oneshot mode for stream log read
This will terminate the connection after all log messages have been
sent. Useful for logread without follow
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Mon, 6 Nov 2017 10:15:39 +0000 (11:15 +0100)]
logread: terminate after EOF
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Mon, 6 Nov 2017 10:11:49 +0000 (11:11 +0100)]
logd: only create pipe in stream mode
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Mon, 6 Nov 2017 09:46:38 +0000 (10:46 +0100)]
logd: use uloop instead of ustream_fd for syslog
Using a stream buffer for a datagram socket makes no sense. This change
fixes dealing with line buffer truncation on large incoming messages
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Rosen Penev [Mon, 30 Oct 2017 19:05:30 +0000 (12:05 -0700)]
log/syslog: Add missing static to two structs.
On x86, binary size goes down by 16 bytes.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Rosen Penev [Mon, 30 Oct 2017 19:05:31 +0000 (12:05 -0700)]
ubox: Replace { 0 } with {}.
The latter is more compatible with older GCC versions like 4.9. Additionally, initializing with { 0 } produces a warning that only the first field was initialized.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Hans Dedecker [Thu, 31 Aug 2017 12:08:11 +0000 (14:08 +0200)]
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>
Hans Dedecker [Wed, 30 Aug 2017 11:32:43 +0000 (13:32 +0200)]
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>
Hans Dedecker [Wed, 30 Aug 2017 13:09:49 +0000 (15:09 +0200)]
kmodloader: fix possible segfaults
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Hans Dedecker [Wed, 30 Aug 2017 13:23:58 +0000 (15:23 +0200)]
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>
Florian Fainelli [Fri, 30 Jun 2017 23:34:22 +0000 (16:34 -0700)]
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>
Alexander Couzens [Sun, 11 Jun 2017 10:33:34 +0000 (12:33 +0200)]
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>
Alexander Couzens [Sun, 11 Jun 2017 10:20:59 +0000 (12:20 +0200)]
kmodloader: insmod: fix a memoryleak in error case
Found-by: Coverity Scan #1412469
Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
Alexander Couzens [Sun, 11 Jun 2017 10:13:05 +0000 (12:13 +0200)]
kmodloader/get_module_name: null-terminate the string
Found-by: Coverity Scan #1412291
Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
Dan Bugnar [Fri, 10 Mar 2017 10:06:29 +0000 (12:06 +0200)]
syslog: remove unnecessary sizeof struct between messages
The next message needs to be written after the data of current message.
This was adding "sizeof(struct log_head)" bytes between messages.
Signed-off-by: Dan Bugnar <danutbug@gmail.com>
Yousong Zhou [Fri, 3 Mar 2017 02:32:48 +0000 (10:32 +0800)]
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>
Yousong Zhou [Thu, 23 Feb 2017 03:04:50 +0000 (11:04 +0800)]
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>
Felix Fietkau [Tue, 21 Feb 2017 13:11:03 +0000 (14:11 +0100)]
cmake: fix typo
Fixes: fce9382b4b99 ("cmake: Check for getrandom system call")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Nathan Hintz [Tue, 21 Feb 2017 05:14:24 +0000 (05:14 +0000)]
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>
Florian Fainelli [Sun, 5 Feb 2017 02:41:34 +0000 (18:41 -0800)]
cmake: Check for getrandom system call
In case we are building against a kernel that is too old and does not
support SYS_getrandom, error out with a message indicating so.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Kevin Darbyshire-Bryant [Sun, 29 Jan 2017 09:23:15 +0000 (09:23 +0000)]
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>
Wojciech Dubowik [Mon, 23 Jan 2017 10:30:14 +0000 (11:30 +0100)]
ubox: Add an option for more accurate timestamps in log
Systemwide timestamps for syslog messages with ms accuracy are usefull
for debugging timing problems.
Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
Yousong Zhou [Fri, 13 Jan 2017 17:00:35 +0000 (01:00 +0800)]
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>
Yousong Zhou [Fri, 13 Jan 2017 17:00:34 +0000 (01:00 +0800)]
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>
Yousong Zhou [Fri, 13 Jan 2017 17:00:33 +0000 (01:00 +0800)]
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>
Yousong Zhou [Fri, 13 Jan 2017 17:00:32 +0000 (01:00 +0800)]
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>
Yousong Zhou [Fri, 13 Jan 2017 17:00:31 +0000 (01:00 +0800)]
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>
Yousong Zhou [Fri, 13 Jan 2017 17:00:30 +0000 (01:00 +0800)]
kmodloader: remove redundant glob wildcard char
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Rosen Penev [Sun, 18 Dec 2016 00:48:47 +0000 (16:48 -0800)]
ubox: Initialize conditionally uninitialized variabled
fixes false positive warning from "-Wconditional-uninitialized in clang"
Signed-off by: Rosen Penev <rosenp@gmail.com>
Rosen Penev [Sun, 18 Dec 2016 01:12:28 +0000 (17:12 -0800)]
ubox: Fix some memory leaks
Avoids leaking memory when exiting early.
Signed-off by: Rosen <rosenp@gmail.com>
Florian Fainelli [Sun, 4 Dec 2016 02:09:39 +0000 (18:09 -0800)]
kmodloader: Fix typo in error message
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Felix Fietkau [Mon, 26 Sep 2016 14:28:52 +0000 (16:28 +0200)]
logd: put non-streamed log entries into one result message
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Alexandru Ardelean [Sat, 24 Sep 2016 08:03:13 +0000 (11:03 +0300)]
ubox/logd: free ubus context on exit
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Alexandru Ardelean [Sat, 24 Sep 2016 08:03:12 +0000 (11:03 +0300)]
ubox/logd: free regex's on log_shutdown() call
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Felix Fietkau [Thu, 22 Sep 2016 18:20:29 +0000 (20:20 +0200)]
logd: fix default initialization of line count
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Thu, 22 Sep 2016 14:55:28 +0000 (16:55 +0200)]
logd: add support for sending log messages as replies
Useful for JSON-RPC access via uhttpd
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Thu, 22 Sep 2016 14:39:49 +0000 (16:39 +0200)]
add getrandom to .gitignore
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Felix Fietkau [Fri, 5 Aug 2016 11:08:53 +0000 (13:08 +0200)]
getrandom: fix indentation, add missing return statement
Signed-off-by: Felix Fietkau <nbd@nbd.name>
John Crispin [Wed, 17 Aug 2016 02:32:43 +0000 (04:32 +0200)]
fix segfault in kmodloader when no modules path was present
Signed-off-by: John Crispin <john@phrozen.org>
Jo-Philipp Wich [Sat, 16 Jul 2016 12:52:36 +0000 (14:52 +0200)]
validate: fix datatype handling of default values
Properly handle the datatype of default values when the corresponding uci
value is unset. Also consolidate the three default value code branches into
a single one.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Hauke Mehrtens [Wed, 13 Jul 2016 14:55:20 +0000 (16:55 +0200)]
kmodloader: fix lsmod depends output
Without this patch only the first dependency is shown, with this patch
all module dependencies are show.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Florian Fainelli [Fri, 1 Jul 2016 23:05:23 +0000 (16:05 -0700)]
cmake: Find uci header file
Add a CMake FIND_PATH and INCLUDE_DIRECTORIES searching for uci.h. Some
external toolchains which do not include standard locations would fail
to find the header otherwise.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Etienne CHAMPETIER [Thu, 9 Jun 2016 13:03:00 +0000 (13:03 +0000)]
getrandom: add helper for getrandom() syscall
getrandom() was introduced in version 3.17 of the Linux kernel.
By default getrandom() block until /dev/urandom pool has been initialized
and then read from it.
Read buffer is 256 bytes so getrandom() calls always succeed.
First usage will be to save a seed for /dev/urandom.
Signed-off-by: Etienne CHAMPETIER <champetier.etienne@gmail.com>
Felix Fietkau [Mon, 7 Mar 2016 16:34:31 +0000 (17:34 +0100)]
kmodloader: fix NULL pointer deref in case m->depends is missing
Observed on an invalid module
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Jo-Philipp Wich [Tue, 9 Feb 2016 12:49:55 +0000 (13:49 +0100)]
kmodloader: clean up memory mapping and fix fd leaks in error handling
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Jo-Philipp Wich [Tue, 9 Feb 2016 07:53:28 +0000 (08:53 +0100)]
kmodloader: fix open() error handling
Fixes kmodloader on systems without stdio and prevents fd leaks in case
descriptor zero is opened.
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Felix Fietkau [Sun, 24 Jan 2016 08:19:53 +0000 (09:19 +0100)]
logread: ensure that the len < sizeof(struct blob_attr) check runs before trying to access the data
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Hauke Mehrtens [Sun, 22 Nov 2015 14:45:27 +0000 (15:45 +0100)]
fix gcc format security error
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Rafał Miłecki [Tue, 14 Jul 2015 06:43:55 +0000 (08:43 +0200)]
log: allow filtering messages with a regexp pattern
This allows printing/streaming/writing messages matching a specified
basic regular expression only.
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Luka Perkov [Tue, 21 Apr 2015 17:04:46 +0000 (19:04 +0200)]
logd: optimize notify function
No need to construct every time the same blob_buf for each client in the list.
Signed-off-by: Luka Perkov <luka@openwrt.org>
Luka Perkov [Tue, 21 Apr 2015 17:04:45 +0000 (19:04 +0200)]
log: make valgrind less complain by freeing allocated memory
Signed-off-by: Luka Perkov <luka@openwrt.org>
Luka Perkov [Tue, 21 Apr 2015 17:04:44 +0000 (19:04 +0200)]
log: fix whitespaces
Signed-off-by: Luka Perkov <luka@openwrt.org>
Luka Perkov [Tue, 21 Apr 2015 17:04:43 +0000 (19:04 +0200)]
log: remove unused callbacks
Signed-off-by: Luka Perkov <luka@openwrt.org>
Etienne CHAMPETIER [Wed, 1 Apr 2015 23:14:01 +0000 (01:14 +0200)]
logread: add support for non-transparent-framing for Syslog over TCP
https://tools.ietf.org/html/rfc6587#section-3.4.2
the idea is to add \n or \0 as message trailer so it's easier
to find message end
v2: simplify, use \n by default, with optional \0
Signed-off-by: Etienne CHAMPETIER <champetier.etienne@gmail.com>
John Crispin [Sat, 28 Mar 2015 14:38:09 +0000 (15:38 +0100)]
properly handle return codes
Signed-off-by: John Crispin <blogic@openwrt.org>
John Crispin [Sat, 28 Mar 2015 06:59:38 +0000 (07:59 +0100)]
properly handle return code of pipe() syscall
Signed-off-by: John Crispin <blogic@openwrt.org>
Christian Mehlis [Thu, 26 Mar 2015 13:51:21 +0000 (14:51 +0100)]
syslog: use appropriate levels for logging
Signed-off-by: Christian Mehlis <christian@m3hlis.de>
Jo-Philipp Wich [Thu, 26 Feb 2015 21:17:31 +0000 (22:17 +0100)]
kmodloader: initialize module folders in insmod
Fixes a segmentation fault in 'insmod' operation mode, due to uninitialized
path list.
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Jo-Philipp Wich [Wed, 25 Feb 2015 20:48:05 +0000 (21:48 +0100)]
kmodloader: convert to ulog() api
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>