summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* depmod: shut up gcc insufficinet buffer warningHEADmasterMichal Suchanek2018-12-171-16/+38
| | | | | | | | | | | | | In a couple of places depmod concatenates the module directory and filename with snprintf. This can technically overflow creating an unterminated string if module directory name is long. Use openat instead as is done elsewhere in depmod. This avoids the snprintf, the extra buffer on stack, and the gcc warning. It may even fix a corner case when the module direcotry name is just under PATH_MAX. [ Lucas: fix up coding style and closing fd on error path ] Signed-off-by: Michal Suchanek <msuchanek@suse.de>
* depmod: prevent module dependency files corruption due to parallel invocation.Michal Suchanek2018-12-171-2/+7
| | | | | | | | | | | | | | | Depmod does not use unique filename for temporary files. There is no guarantee the user does not attempt to run mutiple depmod processes in parallel. If that happens a temporary file might be created by depmod(1st), truncated by depmod(2nd), and renamed to final name by depmod(1st) resulting in corrupted file seen by user. Due to missing mkstempat() this is more complex than it should be. Adding PID and timestamp to the filename should be reasonably reliable. Adding O_EXCL as mkstemp does fails creating the file rather than corrupting existing file. Signed-off-by: Michal Suchanek <msuchanek@suse.de>
* depmod: prevent module dependency files missing during depmod invocationMichal Suchanek2018-12-171-1/+0
| | | | | | | | | | | depmod deletes the module dependency files before moving the temporary files in their place. This results in user seeing no dependency files while they are updated. Remove the unlink call. The rename call should suffice to move the new file in place and unlink the old one. It should also do both atomically so there is no window when no dependency file exists. Signed-off-by: Michal Suchanek <msuchanek@suse.de>
* Remove bootstrap* scriptsLucas De Marchi2018-12-177-74/+74
| | | | | | Let's just use autogen.sh, no need for wrapper scripts. Now `autogen.sh c` uses the same recommended options for developing kmod and also accepts extra arguments.
* README: Add link to mailing list archiveLucas De Marchi2018-11-301-0/+1
| | | | We now have a proper archive for the mailing list.
* signature: do not report wrong data for pkc#7 signatureYauheni Kaliuta2018-11-162-19/+39
| | | | | | | | | | | | | | when PKC#7 signing method is used the old structure doesn't contain any useful data, but the data are encoded in the certificate. The info getting/showing code is not aware of that at the moment and since 0 is a valid constant, shows, for example, wrong "md4" for the hash algo. The patch splits the 2 mothods of gethering the info and reports "unknown" for the algo. Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
* testsuite: add simple test for --show-exportsLucas De Marchi2018-11-133-0/+24
|
* modprobe: add --show-exportsYauheni Kaliuta2018-11-131-0/+36
| | | | | | | | | | | | | | | | | modprobe has --show-modversions switch, which dumps symbols with their modversion crcs from the __versions sections. At the moment the section contains information for the dependency symbols only, while exported symbols add to symtab entries with __crc_ prefix (the format may differ, see 1e48901166ef libkmod-elf: resolve CRC if module is built with MODULE_REL_CRCS). The patch makes it to show exported symbols as well. The function is basically cut'n'paste of show_modversions(), but 'version' family replaced with 'symbol' one. Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
* mkosi: allow Clear to use test modulesLucas De Marchi2018-10-102-7/+3
| | | | Now Clear has a bundle for the kernel headers, let's use it.
* man: depmod: remove deprecated -m optionLucas De Marchi2018-07-201-1/+0
| | | | Thanks to Howard Johnson <hwj@bridgeportcontractor.com> for noticing.
* kmod: build: cure compiler warnings showing up externallyJan Engelhardt2018-06-181-2/+2
| | | | | | | | | | When building a C source file with gcc-7 -Wshift-overflow=2, this warning springs up: libkmod.h: warning: result of "1 << 31" requires 33 bits to represent, but "int" only has 32 bits [-Wshift-overflow=] Change the two _KMOD_* identifiers to fit into 32 bits.
* build: fix wrong quotes on bootstrapJakov Simunic2018-05-161-1/+1
|
* Phrasing correction in modprobe man pageChris Stackpole2018-05-141-1/+1
|
* libkmod-module: check for NULL before accessing pointersLuca Bruno2018-04-052-13/+15
| | | | | | | | This introduces a few missing NULL-checks in public functions, and align their docstrings with real behavior by getting rid of copy-paste mistakes. Signed-off-by: Luca Bruno <luca.bruno@coreos.com>
* testsuite: raise arch image to 3GBLucas De Marchi2018-02-091-1/+1
|
* testsuite: add Clear's mkosi configurationCaio Marcelo de Oliveira Filho2018-02-082-2/+26
| | | | | Adapted the mkosi.build script to account for not building test-modules in Clear. It doesn't have the headers available yet.
* kmod 25v25Lucas De Marchi2018-01-083-2/+25
|
* testsuite: also wrap gettid in syscall()Lucas De Marchi2018-01-081-0/+21
| | | | | | Not a perfect solution for overriding syscall(), but at least it makes the testsuite to pass in a modified nsswitch.conf (one that has a module which calls syscall() to get the thread id).
* testsuite: explain why overriding function may failLucas De Marchi2018-01-031-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | On my computer `testsuite/test-modprobe modprobe_install_cmd_loop` was failing because when it forks off the shell the child process ends up calling syscall() which are are supposed to wrap. Here's the backtrace: #0 0x00007ffff6fdb66b in raise () from /lib64/libc.so.6 #1 0x00007ffff6fdd381 in abort () from /lib64/libc.so.6 #2 0x00007ffff77bac97 in syscall (__sysno=<optimized out>) at testsuite/init_module.c:362 #3 0x00007fffef92d4e7 in hashmap_base_new.lto_priv () from /lib64/libnss_systemd.so.2 #4 0x00007fffef953f50 in sd_bus_open_system () from /lib64/libnss_systemd.so.2 #5 0x00007fffef943123 in _nss_systemd_getpwuid_r () from /lib64/libnss_systemd.so.2 #6 0x00007ffff707eea5 in getpwuid_r@@GLIBC_2.2.5 () from /lib64/libc.so.6 #7 0x00007ffff707e608 in getpwuid () from /lib64/libc.so.6 #8 0x00005555555859e1 in get_current_user_info.part () #9 0x00005555555a375a in initialize_shell_variables () #10 0x0000555555580fde in shell_initialize () #11 0x00005555555846ff in main ()<Paste> The reason it fails on my system and not on, for e.g., a new one set up with mkosi is that the call to getpwuid() depends on the contents /etc/nsswitch.conf. The systemd module calls syscall() to implement gettid() which we can't forward due to being a variadic function. No fix is provided here, but at least it's explained why this happens.
* testsuite: add missing error handlingLucas De Marchi2018-01-031-0/+2
| | | | | If we passed an invalid argument to a test it would segfault rather than returning an error code.
* testsuite: add Fedora's mkosi configurationLucas De Marchi2018-01-032-1/+27
| | | | | | | | | | To use the Fedora configuration rather than the default, one should use: # make DISTRO=fedora mkosi While at it also reduce the root partition size for Arch, since it doesn't need that much.
* testsuite: generalize mkosi support for other distrosLucas De Marchi2018-01-035-11/+29
| | | | | | | | | | | | | Instead of using the mkosi.default symlink, use an env var passed from the build system. We would need to pass the --default switch nonetheless or change the symlink, making the git tree dirty. Also, search for installed kernel headers in a way that's compatible with more distros. On Fedora, for example, the /usr/lib/modules/<kver>/build symlink is only available if there's a kernel installed. We don't care about a kernel installed since we don't need to boot it on a real machine: the only thing we need is the kernel-devel package.
* build: use tool from configureLucas De Marchi2018-01-022-2/+3
| | | | | This way we make sure the tool will be the one we actually configured before going through sudo.
* build: add mkosi hooksLucas De Marchi2018-01-025-0/+58
| | | | Right now there's support for building on Archlinux only.
* depmod: module_is_higher_priority: fix modname length calculationYauheni Kaliuta2017-12-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | depmod_module_is_higher_priority checks module's path if it is under module root directory and if so uses relative to the root path to lookup the module in override and search lists. Originally only relative path was used in the function, so the variables with full path and and path length were changed: newpath += cfg->dirnamelen + 1; newlen -= cfg->dirnamelen + 1; oldpath += cfg->dirnamelen + 1; oldlen -= cfg->dirnamelen + 1; Commit 7da6884e7357ac05772e90f6d7e63b1948103fc4 (depmod: implement external directories support) changed the logic since it need the full path to the module for comparations as well. Unfortunately, it introduce a mistake in calculation of the relative paths replacing '-=' with assignment to a new variable -- the 'cfg->dirnamelen + 1' value must be substracted all together. It breaks, for example, overrides lookup. Fix the calculation by putting braces around the value in the subsctuction expression. Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
* testsuite: depmod: add override testYauheni Kaliuta2017-12-075-0/+31
| | | | | | | | | | | | Simple test to check if depmod honors override keyword. Uses mod-simple.ko for foo/ and override/ directories, search.conf to search in foo and built-in and simple override configuration: override mod-simple 4.4.4 override The resulting modules.dep should point to the override directory. Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
* depmod: Don't add .TOC. when it's in the kernel.Michal Suchanek2017-12-071-1/+2
| | | | | | | | | | d46136bb59c4 ("depmod: Ignore PowerPC64 ABIv2 .TOC. symbol") adds fake .TOC. unconditionally but when there is .TOC. in the kernel adding the fake one breaks resolving .TOC. Fixes: d46136bb59c4 ("depmod: Ignore PowerPC64 ABIv2 .TOC. symbol") Signed-off-by: Michal Suchanek <msuchanek@suse.de>
* man/depmod: Add references in other man pagesChristopher Díaz Riveros2017-10-164-0/+12
| | | | | | | | | | | | | | Depmod man page is not referenced in some man pages. This makes it harder to find through reading documentation. References added to: -man/insmod.xml -man/lsmod.xml -man/modprobe.xml -man/rmmod.xml Signed-off-by: Christopher Díaz Riveros <chrisadr@gentoo.org>
* libkmod-elf: resolve CRC if module is built with MODULE_REL_CRCSYauheni Kaliuta2017-08-041-1/+29
| | | | | | | | | | | | | | | | Normally exported symbol's crc is stored as absolute (SHN_ABS) value of special named symbol __crc_<symbol name>. When the kernel and modules are built with the config option CONFIG_MODULE_REL_CRCS, all the CRCs are put in a special section and the __crc_<symbol name> symbols values are offsets in the section. See patch description of the commit: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=56067812d5b0e737ac2063e94a50f76b810d6ca3 Add kmod support of this configuration. Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
* man/depmod.d: add external keyword descriptionYauheni Kaliuta2017-07-211-0/+20
| | | | | | | | | | The commit 'depmod: implement external directories support' added external directories support (see 7da6884e7357ac05772e90f6d7e63b1948103fc4). This patch documents the extention in the manpage. Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
* shared/util.c: assert_cc() can only be used inside functionsThomas Petazzoni2017-06-051-2/+4
| | | | | | | | | | | | | | | | shared/macro.h has two versions of assert_cc, one that uses gcc _Static_assert(), which requires recent enough gcc versions, and one that uses a fake array to trigger a build error. The latter can only work inside functions, so assert_cc() should only be used inside functions. Fixes the following build failure when building kmod with old gcc versions such as gcc 4.3.x: shared/util.c:52: error: expected identifier or '(' before 'do' shared/util.c:52: error: expected identifier or '(' before 'while' Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
* testsuite: add tests for external directory supportYauheni Kaliuta2017-06-0130-0/+118
| | | | | | | | | | | | | | | The following tests added: - depmod_search_order_external_first -- checks if external module is taken in use when it has higher priority; - depmod_search_order_external_last -- checks if external module is skipped when it has lower priority; - test_modinfo_external -- checks if modinfo is able to look up correct external module; - modprobe_external -- checks if modprobe is able to look up correct external module and loads it. Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
* depmod: implement external directories supportYauheni Kaliuta2017-06-011-22/+150
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The idea is to add a configuration keyword, external, which will list directories for scanning for particular kernel version mask: external 4.10 /the/modules/dir /second/modules/dir And extend "search" keyword to set it's priority with pseudo dir "external" (as it's done for built-in): search subdir external subdir2 built-in subdir3 (actually, the version is the same as for override keyword: * or posix regexp, so example above is a bit incorrect). All other logic left the same: if there are duplicates, only one is under consideration and it is unloadable if it is bad. The resulting modules.dep will contain entries a-la: /the/modules/dir/module1.ko: kernel/module2.ko: /the/modules/dir/module1.ko (here /lib/modules/$(uname -r)/kernel/module2.ko depends of symbols, provided by /the/modules/dir/module1.ko and external has higher priority). modprobe and modinfo understand it out of box. This is a pretty simple extention of existing logic, since now depmod already is able to: a) scan modules with full path from command line without -a switch; b) detects broken symbol dependencies and broken modversions, what assumes, that modules are already are not built for the existing kernel. Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
* test-depmod: avoid warning when we don't have zlibLucas De Marchi2017-06-011-1/+1
| | | | | | testsuite/test-depmod.c:31:21: warning: ‘depmod_modules_order_for_compressed’ defined but not used [-Wunused-function] static noreturn int depmod_modules_order_for_compressed(const struct test *t) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* depmod: rewrite depmod modules search with scratchbufYauheni Kaliuta2017-06-011-12/+21
| | | | | | | | | | | | The recursive search code used used pretty big, PATH_MAX, automatic storage buffer for the module directory scanning. Some time ago there was scratchbuf implemented, which dynamically reallocates its buffer on demand. The patch takes it in use for the scanning code also. The initial size is hardcoded to 256 bytes which sounds good enough for most usecases so there should be not many reallocations. Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
* depmod: create depmod dir independent search functionYauheni Kaliuta2017-06-011-9/+22
| | | | | | | | | | | | | Prepare to implement external directories support. The patch splits depmod_modules_search() function to two functions: depmod_modules_search(), called by the high level with intention to search all possible modules, and depmod_module_search_path(), which takes path as a parameter and scans modules under the path only. Initially it is used to scan the same depmod->cfg->dirname path only. Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
* depmod: search key: move builtin detection under the add functionYauheni Kaliuta2017-05-091-4/+4
| | | | | | | | | | | | | Prepare to implement external directories support. It's better to isolate behaviour difference under the cfg_search_add() call, then make the client code aware of it. In case of external modules/directories support, there will be one more keyword added, so making the clients aware of it makes even less sense. Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
* depmod: fix errorpath memleaks in report cycles logicYauheni Kaliuta2017-05-081-17/+37
| | | | | | | | | | | The c7ce9f0c80f3d561078a78205a14c5ba7663cfdd commit (depmod: handle nested loops) introduced a bunch of possible memory leaks in error path. In the real world scenario it is not a problem, since the utility quits if it detects any of the errors, but from the programming point of view, it is not nice. So, add the cleanups. Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
* libkmod: modinfo: implement signature outputYauheni Kaliuta2017-04-113-1/+16
| | | | | | | Signature was ignored from the modinfo. Implement its parsing from the module data and add its output to the modinfo utility. Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
* libkmod: modinfo: implement line splitting in hex_to_strYauheni Kaliuta2017-04-111-5/+15
| | | | | | | | | | The key output is usually short, but for signature it is more readable to output it in several lines. Implement line splitting. Set line limit hardcoded to 20 hex numbers (not characters). Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
* libkmod: modinfo: use own function for sig_key hex outputYauheni Kaliuta2017-04-111-25/+54
| | | | | | | | | | | | Refactor the code a bit to make it easier to extend for signature output. kmod_module_get_info() creats a hex string for the sig_key data inplace. Separate it into own kmod_module_hex_to_string function and handle the branch in the new kmod_module_info_append_hex, keeping the same signature as the non-hex version. Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
* libkmod: modinfo: fix sig_id outputYauheni Kaliuta2017-04-111-1/+1
| | | | | | | | | | For some reason the key for sig_id was set to "signature". The length was calculated against the proper string, as the result in the output it was truncated to "signat". Pass the proper key to the kmod_module_info_append() call. Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
* kmod 24v24Lucas De Marchi2017-02-233-2/+20
|
* build: update autogenLucas De Marchi2017-02-231-16/+50
| | | | Bring new options from systemd and other projects.
* depmod: fix leak on error pathLucas De Marchi2017-02-231-1/+2
|
* man: make error message clearer for missing xstlprocLucas De Marchi2017-02-231-7/+7
| | | | | | | | | | | | | | | We can't do at configure phase since we actually ship the built man pages with dist, so it's fine not having xsltproc if building from dist. If building from the repository, it's better to have have a better message saying xsltproc was not found than trying to execute the argument to xsltproc. Now message is: XSLT depmod.d.5 /bin/sh: line 1: xsltproc: command not found Instead of: XSLT depmod.d.5 /bin/sh: --nonet: command not found
* build: add missing headerLucas De Marchi2017-02-231-0/+1
| | | | Fix failing distcheck
* depmod: handle nested loopsYauheni Kaliuta2017-02-221-84/+211
| | | | | | | | | | | | | | | | | | This is a rework of depmod report cycles logic to make it tolerant to more complex loops. The patch tries to remember own path for vertexes which makes it possible to handle configurations with common edges and non-cyclic modules. It assumes that the previous dependency calculations can not give as input something like mod_a -> mod_b -> <loop>, but <loop> -> mod_a -> mod_b should be fine. Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
* testsuite: depmod: check netsted loops reportingYauheni Kaliuta2017-02-2213-2/+124
| | | | | | | | | | | | | | | | | | | | | | | | | The patch adds nested loops configuration for the loop test: mod-loop-h -> mod-loop-i -> mod-loop-j -> mod-loop-k ^ | | --------------------------- | | | ------------------------------------------- making 2 loops with common edges: mod-loop-h -> mod-loop-i -> mod-loop-j -> mod-loop-h mod-loop-h -> mod-loop-i -> mod-loop-j -> mod-loop-k -> mod-loop-h The actual output for the loops is: depmod: ERROR: Cycle detected: mod_loop_h -> mod_loop_h depmod: ERROR: Cycle detected: mod_loop_i -> mod_loop_j -> mod_loop_k -> mod_loop_h -> mod_loop_i (the order in the second doesn't matter, but the first one is incorrect) Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
* libkmod-config: fix parsing quoted kernel cmdline on paramsLucas De Marchi2017-02-162-1/+15
| | | | We can only accept quoted values, not module names or parameter names.