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>
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>
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)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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>
Add some tests in which we quotes in kernel cmdline and also spaces
inside quotes. This doesn't yet cover the case in which quotes are used
for module name, wihch should be forbidden.
install: cannot stat 'testsuite/module-playground/mod-loop-f.ko': No
such file or directory
Makefile:2881: recipe for target 'rootfs' failed
make[1]: *** [rootfs] Error 1
make[1]: *** Waiting for unfinished jobs....
Makefile:2101: recipe for target 'check-recursive' failed
We need to ship pre-compiled binaries so it's possible to run
"make check" on servers without kernel headers.
Also add them to EXTRA_DIST as other sources.
Only print actual cyclic dependencies. Print count of all the modules
in cyclic dependency at the end of the function so that dependent
modules which are not in cyclic chain can be ignored.
Printing dependent modules which are not in cyclic chain causes buffer
overflow as m->modnamesz is not included in buffer size calculations
(loop == m is never true). This buffer overflow causes kmod to crash.
Update depmod test to reflect the change as well.
Reported-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@suse.com>
Check that depmod do not report modules outside cyclic chain
Two modules f and g are added which do not have any dependency.
modules a and b are made dependent on f and g.
Here is the output of loop dependency check test after adding this
patch:
TESTSUITE: ERR: wrong:
depmod: ERROR: Found 7 modules in dependency cycles!
depmod: ERROR: Cycle detected: mod_loop_d -> mod_loop_e -> mod_loop_d
depmod: ERROR: Cycle detected: mod_loop_b -> mod_loop_c -> mod_loop_a -> mod_loop_b
depmod: ERROR: Cycle detected: mod_loop_b -> mod_loop_c -> mod_loop_a -> mod_loop_g
depmod: ERROR: Cycle detected: mod_loop_b -> mod_loop_c -> mod_loop_a -> mod_loop_f
Buffer overflow occurs in the loop when last two lines are printed.
43 bytes buffer is allocated and 53 bytes are used.
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@suse.com>
The array elements in the tests are strings, what means "char *"
in С. The comparation funtion takes pointers to the elements, so
the arguments become "char **". It means, that strcmp() cannot be
used directrly.
The patch creates a wrapper on strcmp() which perfoms
dereferencing of the "char **" to supply the actual strings to
strcmp(), and uses the wrapper as a comparation function for the
qsort() call.
Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
This should fill the requirements for "we need to loop over a lot of
strings that usually are small enough to remain on stack, but we want to
protect ourselves against huge strings not fitting in the static
buffer we estimated as sufficient"
shared/util.c: In function ‘read_str_safe’:
shared/util.c:211:24: warning: logical ‘or’ of equal expressions [-Wlogical-op]
if (errno == EAGAIN || errno == EWOULDBLOCK ||
^~
shared/util.c: In function ‘write_str_safe’:
shared/util.c:237:24: warning: logical ‘or’ of equal expressions [-Wlogical-op]
if (errno == EAGAIN || errno == EWOULDBLOCK ||
^~
This is because EAGAIN and EWOULDBLOCK have the same value. Prefer
EAGAIN, but add a static assert to catch if it's not the same in another
architecture.
Now that we are able to build our own test modules, also allow to use
cached modules so a) kernel headers are not required and b) distro
maintainers are happy. It's still need a "--disable-test-modules" in
the configure since the default is enabled.
There's no license problems anymore since all modules come from our own
repository, we ship the sources and the modules can be easily rebuilt.
The second test, that creates the module by name and then retrieves the
initstate was broken before b95fa91 ('Fix race while loading modules').
We would check /sys and return either builtin (if the module has
parameters) or give an error because we don't find the module (even if
it's in the modules.builtin index)
We use a "fake signature" to sign the modules. As far as kmod is
concerned the signature fields are informational only. It's the kernel
the responsible for checking it's valid.
So what we are doing here is: pick the signatures of the ext4-x86_64.ko
module and save as dummy.{hashalgo}. This signature is appended to the
mod-simple.ko module so the ext4-x86_64.ko module can be removed from
tree.
Rename modinfo_jonsmodules() to test_modinfo_signature(): now this test
is responsible only for the signed modules.
The other tests use specific flags to modinfo in order to print only
one field, so we can filter out those fields that are expect to change
if the module is recompiled.
This is for convenience for development and testing since we don't want
to needlessly cross-compile the modules. There's a README file
explaining the building process for those who want to update them.
These files are compiled from their respective .c and thus have LPGL
license.
If we were expecting output on stdout or stderr but the test didn't
produce any, we were incorrectly assuming the test was successful.
Now test on exit if there was activity on the monitored fd. If there
was, check also if the file size to check for output is > 0 for the
cases in which we want to assert there was no activity on certain fd.
This adds the needed infra to cross-compile modules so we can test them
in our testsuite. Right now we are only compiling mod-simple.ko for x86,
x86_64 and sparc64.
The makefiles are organized in a way it's easy to force a rebuild of a
module by calling the Makefile.arch directly and that allows the rule in
Makefile to not trigger in case we want to ship the modules
pre-compiled.
Use _builtin_uaddll_overflow/_builtin_uaddl_overflow when available,
abstracting the type to use it with uint64_t.
Otherwise fallback to the implementation as added in 67466f2 ("Prevent
offset + size overflow.").
This also adds the tests for this new helper in the testsuite.
Instead of shipping pre-compiled module, this prepares the build system
to be able to compile the necessary modules from module-playground. This
preparations starts by replacing md5.ko with our own dummy
mod-simple.ko, built from source. It works by copying the modules to
their final location while preparing the rootfs.
Some tests cover internal API that wasn't used
elsewhere. The choice here was to test and keep the
list implementation complete instead of removing it.