summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* testsuite: add test for modprobe -R <builtin-module>test-broken-initstateLucas De Marchi2015-02-272-0/+23
|
* modprobe: stop checking initstate for builtin modulesLucas De Marchi2015-02-271-30/+4
| | | | | | builtin modules are handled in libkmod by looking at the modules.builtin index. There's no need to check again for the module's initstate to decide if it's builtin.
* testsuite: test builtin stateLucas De Marchi2015-02-2713-1/+139
| | | | | | | | 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)
* Fix race while loading modulesHarish Jenny K N2015-02-273-19/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | usecase: two sd cards are being mounted in parallel at same time on dual core. example modules which are getting loaded is nls_cp437. While one module is being loaded , it starts creating sysfs files. meanwhile on other core, modprobe might return saying the module is KMOD_MODULE_BUILTIN, which might result in not mounting sd card. Experiments done to prove the issue in kmod. Added sleep in kernel module.c at the place of creation of sysfs files. Then tried `modprobe nls_cp437` from two different shells. While the first was still waiting for its completion , the second one returned saying the module is built-in. [ Lucas: The problem is that the creation of /sys/module/<name> and /sys/module/<name>/initstate are not atomic. There's a small window in which the directory exists but the initstate file was still not created. built-in modules can be handled by searching the modules.builtin file. We now enforce mod->builtin to always be up-to-date when kmod_module_get_initstate() is called. This way if the directory exists but the initstate doesn't, we can be sure this is because the module is in the "coming" state, i.e. kernel didn't create the file yet, but since builtin modules were already handled by checking our index, the only reason for that to happen is that we hit the race condition. I also added some tweaks to the patch, so we don't repeat the code for builtin lookup. ]
* shared: avoid checking for __STDC_VERSION__Lucas De Marchi2015-02-262-1/+9
| | | | | | | | | | Since we pass -std=gnu99 to the compiler __STDC_VERSION__ is defined to 199901. Even in this case we can use _Noreturn. Delegate the testing to the configure phase with a compile test. In future we want to stop using AC_PROG_CC_99 and start using the new AC_PROG_CC from autoconf 2.70, which tries to choose the most recent standard.
* build: simplify and organize configureLucas De Marchi2015-02-261-18/+11
| | | | | | | | | | | - There's no need for the various AC_PROG_CC* macros - No need for AC_C_BIGENDIAN: the only place we care about endianness, we use __BYTE_ORDER - Organize calls to be in similar order as systemd - Disable --disable-largefile. We already had possible bugs in the index implementation if this were passed. It's now fixed, but it's never tested. Disable it. - Bump autoconf requirement to 2.64
* depmod: fix leak in case of malloc(0)Lucas De Marchi2015-02-261-1/+2
| | | | | | malloc(0) can return != NULL. We need to pass the pointer to free(). This happens if index__haschildren(node) returned true, but child_count is set to 0.
* build: add helpers to upload coverity tarballLucas De Marchi2015-02-252-0/+26
|
* depmod: use cleanup attribute to simplify free on exitLucas De Marchi2015-02-251-12/+5
| | | | | | | | | Reusing the root variable was a bad idea. Doing so we could call free() on a variable that was not allocated. For example: "depmod -b / -h". Since we would jump to cmdline_failed, root would not be duplicated. Instead of fighting the order in the options, just used the cleanup attribute and remove the calls to free() on "config_paths" and "root".
* depmod: Fix crash in previous commit if root is not setColin Walters2015-02-251-1/+1
| | | | | | | [This fixes http://build.gnome.org/continuous/buildmaster/builds/2015/02/25/31/build/output.txt ] The variable we're reading here is "root", not "optarg" which is only valid inside the getopt call.
* depmod: fix leaking root on exitLucas De Marchi2015-02-251-1/+5
|
* from systemd: build: make sure to test for -Wflag instead of -Wno-flagDavid Herrmann2015-02-241-2/+3
| | | | | | | | gcc does not support testing for negated warnings. See here for details: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63499 This patch changes CC_CHECK_FLAG_APPEND to always test for the non-negated warnings.
* from systemd: build-sys: fix conftest.c to work on armZbigniew Jędrzejewski-Szmek2015-02-241-1/+1
| | | | | | All tests for compiler support were failing with: /usr/bin/ld: /tmp/ccwnVc2A.o: relocation R_ARM_MOVW_ABS_NC against `a' can not be used when making a shared object; recompile with -fPIC
* from systemd: build: check for build/link flags harderDavid Herrmann2015-02-241-3/+3
| | | | | | | | Use AC_LINK_IFELSE instead of AC_COMPILE_IFELSE to test for flags that might succeed during compilation but not during linking. An example is gcc compiled with libssp support but gnu-ld without it. In this case -fstack-protector works fine during compilation but fails during linking as several internal helpers are missing.
* from systemd: build: merge trivial changes backLucas De Marchi2015-02-241-12/+15
| | | | | | | | | These were trivial changes applied to systemd tree since the files were synchronized: - change some comments - replace tab with space - fix typo
* build: add missing files to EXTRA_DISTLucas De Marchi2015-02-241-7/+23
| | | | Fix make distcheck.
* module-playground: don clean all .ko filesLucas De Marchi2015-02-241-4/+6
| | | | | Rather than calling kernel's make for clean target, do it by ourselves. This way we can preserve some prebuilt modules.
* testsuite: move test-blacklist to DEFINE_TESTMarcus Meissner2015-02-221-4/+3
| | | | | | otherwise the test will not be executed. Signed-Off-By: Marcus Meissner <meissner@suse.de>
* testsuite: port signature-check modules to module-playgroundLucas De Marchi2015-02-219-11/+53
| | | | | | | | | | | 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.
* testsuite: port arch-specific tests to module-playgroundLucas De Marchi2015-02-2113-34/+48
| | | | | | | | | 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.
* fixup! module-playground: allow to cross-compile modulesLucas De Marchi2015-02-211-3/+0
|
* testsuite: leave arch-specific modules in treeLucas De Marchi2015-02-215-0/+27
| | | | | | | | | 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.
* testsuite: add option to copy output from testLucas De Marchi2015-02-212-0/+7
| | | | | This is helpful while debugging the tests: copy the output from test (both stdout and stderr) to the stdout of the parent process.
* testsuite: fix exiting with success on no output activityLucas De Marchi2015-02-211-4/+28
| | | | | | | | 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.
* module-playground: allow to cross-compile modulesLucas De Marchi2015-02-214-1/+45
| | | | | | | | | | | 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.
* testsuite: port modules-order-compressed to module-playgroundLucas De Marchi2015-02-1912-1/+117
|
* Update TODOLucas De Marchi2015-02-191-0/+3
|
* libkmod: better explain a signed module layoutLucas De Marchi2015-02-181-7/+11
|
* libkmod: consider empty signature key as invalidLucas De Marchi2015-02-181-1/+2
| | | | | | | | | | | | | A segmentation fault occurs if a module has an empty key attached to its signature. This is mostly likely due to a corrupted module. The crash happens because kmod_module_get_info() assumes that kmod_module_signature_info() returns a signature of at least 1 byte. The fix is based on a patch from Tobias Stoeckmann <tobias@stoeckmann.org>, but rather than changing kmod_module_get_info() to fix the crash, this changes kmod_module_signature_info() to consider the signature as invalid.
* Fix out of bounds signature access with 32 bit off_tTobias Stoeckmann2015-02-181-1/+1
| | | | | | | | | | If kmod has been configured with --disable-largefile on a 32 bit system, off_t will be 32 bit. In that case, the parsed sig_len can bypass a validation check (it's _unsigned_ 32 bit). Due to the unlikeliness of people using --disable-largefile, this is a mere validation fix. With an explicit signed 64 bit cast, there is no binary change for 99.9% of Linux systems out there. ;)
* libkmod: properly validate file sizeTobias Stoeckmann2015-02-171-5/+5
| | | | | | | | | | | | | | | | | | | In function kmod_elf_new, the file size has to be properly validated against section offset. Currently, the file size is considered valid based on ELF header size + section header size * section count. That is not sufficient. In fact, ELF specifies a section header offset, which doesn't have to be the size of the ELF header. The supplied test cases even cover this. The correct test is: section offset + section header size * section count This patch also verifies that this value won't overflow. I don't know a way to crash a tool due to this bug, because later on the offset check would prevent out-of-bounds access. An overflow would just mean to access a wrong part in elf->memory. Yet it's a validation error. Please note: The file size does not have to be validated against the size of the ELF header again, elf_identify did this already.
* testsuite: port kcmdline test to module-playgroundLucas De Marchi2015-02-1110-7/+5
|
* testsuite: port install-cmd-loop test to module-playgroundLucas De Marchi2015-02-1112-138/+9
|
* testsuite: port alias-to-none test to module-playgroundLucas De Marchi2015-02-1010-7/+5
|
* testsuite: port tests without finit_module() to module-playgroundLucas De Marchi2015-02-1014-14/+10
|
* testsuite: port modprobe --force test to module-playgroundLucas De Marchi2015-02-108-6/+4
|
* testsuite: port softdep-loop test to module-playgroundLucas De Marchi2015-02-1014-71/+9
|
* libkmod: use helper function to check for overflowLucas De Marchi2015-02-101-2/+2
|
* shared: add helper function to add and check for overflowLucas De Marchi2015-02-104-0/+39
| | | | | | | | | | 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.
* build: define to 0 if builtin is not availableLucas De Marchi2015-02-101-3/+5
| | | | | | In order to let us use "#if HAVE__BUILTIN_*" without checking if it's actually define, make sure we define it to 0 in config.h when the function is not available.
* Prevent offset + size overflow.Tobias Stoeckmann2015-02-101-1/+1
| | | | | | | | | | | | | | | | | | | | it is possible to overflow uint64_t by summing variables offset and size up in elf_get_section_info. Thee values are extracted from module file and are possibly maliciously tampered with. If offset is in valid range and size very large, the result will overflow and the size check passes. Later on, this will most likely lead to a segmentation fault due to accessing uninitialized memory. Attached please find a proof of concept module, which will trigger a segmentation fault on modinfo. Tested on amd64: tobias:~$ modinfo poc.ko filename: /home/tobias/poc.ko Segmentation fault There are more errors of this type in the ELF handling code that will be fixed in other patches.
* testsuite: port show-depends tests to module-playgroundLucas De Marchi2015-02-1081-136/+15
| | | | | Another test, modprobe_show_alias_to_none was wrongly checking the output in the show-depends namespace so it needed changing as well.
* build: check for required builtin functionsLucas De Marchi2015-02-102-1/+8
| | | | | | These builtins are implemented by both gcc and clang since a long time and we don't provide fallback for them. Let the configure phase check for them.
* build: add better check for builtin functionLucas De Marchi2015-02-101-21/+15
| | | | | It's not used right now in kmod, but may be used in future for other builtins, so let the macro generic.
* testsuite: port detect-loop test to module-playgroundLucas De Marchi2015-02-0915-9/+154
|
* travis: also test with gcc 4.8 and 4.9Lucas De Marchi2015-02-041-8/+17
|
* travis: use kernel headers for testsuiteLucas De Marchi2015-02-031-0/+3
| | | | Install kernel headers and export KDIR variable to point to right dir.
* testsuite: convert test-init function to use mod-simple.koLucas De Marchi2015-02-0312-62/+8
|
* build: let touch on directory as last stepLucas De Marchi2015-02-031-2/+2
| | | | | | We need to let these instructions in kmod to be the last executed ones. Otherwise the subdirectory containing the modules could propagate up the time access.
* testsuite: port test-dependencies to module-playgroundLucas De Marchi2015-02-0316-79/+125
|