Commit Graph

1292 Commits

Author SHA1 Message Date
Santiago Vila 8feffdfa2e kmod: fix small typo in rmmod(8)
This is how rmmod(8) looks like:

SEE ALSO
       modprobe(8), insmod(8), lsmod(8)modinfo(8)

The attached trivial patch fixes it:

SEE ALSO
       modprobe(8), insmod(8), lsmod(8), modinfo(8)
2015-06-08 22:46:42 -03:00
Lucas De Marchi 655de2751d tools: display features in --version
Reviewed-by: Andreas Mohr <andim2@users.sf.net>
2015-06-08 22:38:02 -03:00
Lucas De Marchi 4671e03e1d build: add relevant features to KMOD_FEATURES in config.h
Not all the features (i.e. those available in --enable-* or --with-*)
are really relevant to the final user. Create a KMOD_FEATURES definition
in config.h containing these features.

Reviewed-by: Andreas Mohr <andim2@users.sf.net>
2015-06-08 22:37:58 -03:00
Lucas De Marchi a968aa64dd build: add function to build string of features
Add a CC_FEATURE_APPEND function that we can use to append the features
that are enabled/disabled. This will generate a single string in the
form "+FEATURE1 +FEATURE2 -FEATURE3".

Reviewed-by: Andreas Mohr <andim2@users.sf.net>
2015-06-08 22:37:10 -03:00
Lucas De Marchi b1499094c6 tools: add PACKAGE definition in message
Reported-by: Andreas Mohr <andim2@users.sf.net>
2015-06-08 21:33:06 -03:00
Lucas De Marchi 013e855043 tools: Hide new commands behind experimental flag
Hide the commands behind a flag so we can continue doing releases while
the commands aren't ready.
2015-06-06 23:26:31 -03:00
Lucas De Marchi 23603f1f83 build: cache modules from playground
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.
2015-05-31 15:38:47 -03:00
Santiago Vila 7266ec4337 Fix spurious spaces in lsmod output
While using "localyesconfig" to build a custom kernel I noticed that
lsmod output now has trailing spaces when the list of "Used by" modules
is empty.

The following patch just delays the space to the point where we are sure
that there are more things to print.
2015-04-16 08:46:43 -03:00
Lucas De Marchi a8c73b8609 util: use UINT64_MAX
Since we are checking the size of long and long long, use UINT64_MAX in
the fallback to be sure thre right size is being used.
2015-03-23 23:47:23 -03:00
Lucas De Marchi 9cc8a20d34 build: sync dolt with upstream 2015-03-10 15:17:03 -03:00
Caio Marcelo de Oliveira Filho 037618816c tools: add basic versions of insert and remove 2015-03-07 12:09:51 -03:00
Caio Marcelo de Oliveira Filho f4f408f9f3 testsuite: update README 2015-03-05 23:56:44 -03:00
Caio Marcelo de Oliveira Filho 0f079cba76 testsuite: remove .gitignore files when populating rootfs
Usually this file is added to keep a directory existing in the
repository but without any real content. In rootfs this can be
problematic if a directory will have all its files inspected. This
happens for kmod_module_get_holders().

Side-note: the 'test-loaded.c' is hit by this problem but doesn't
"notice" because the invalid module returned by get_holders() is not
checked. The modules in its loop are only used to get the name and
generate an output, and NULL was a valid value to generate the name.
2015-03-05 23:56:36 -03:00
Lucas De Marchi da6c0d2f52 build: use dolt
Drop-in replacement to libtool: http://dolt.freedesktop.org/. More
details: http://marc.info/?l=freedesktop-xorg&m=120791871615872&w=3

kmod is relatively fast to compile, so it doesn't matter much.
Nonetheless, less forks the better.

Compilation time using ./bootstrap-configure --disable-manpages and
make -j4

libtool
real    0m6.453s
user    0m21.067s
sys     0m0.773s

dolt
real    0m4.792s
user    0m15.920s
sys     0m0.637s
2015-03-05 13:14:36 -03:00
Lucas De Marchi d9c7175859 kmod 20 2015-03-01 14:43:09 -03:00
Lucas De Marchi f7c243ac59 Update TODO 2015-03-01 14:16:59 -03:00
Lucas De Marchi ebdac0005b Check return of fseek while reading index 2015-02-28 16:11:53 -03:00
Lucas De Marchi d98f2d32d1 Avoid sign-extension error on multiplication
Do not promote "idx * elf->header.section.entry_size" to int. Explicitly
cast the result to uint64_t so it's zero-extended.
2015-02-28 16:07:55 -03:00
Lucas De Marchi 22df456760 depmod: add asserts to ensure positive return from ftell()
Also ignore some errors that will later be returned by ferror().
2015-02-28 14:57:00 -03:00
Lucas De Marchi ade6b25c9a testsuite: add test for modprobe -R <builtin-module> 2015-02-28 14:18:54 -03:00
Lucas De Marchi e2719b32cc modprobe: stop checking initstate for builtin modules
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.
2015-02-28 14:18:54 -03:00
Lucas De Marchi dbf90dc3a8 testsuite: test builtin state
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)
2015-02-28 14:18:54 -03:00
Harish Jenny K N fd44a98ae2 Fix race while loading modules
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 actually lose some "modules" that create entries in /sys/modules
  (e.g. vt) and are not in modules.builtin file: only those that can be
  compiled as module are present in this file.

  We 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.  ]
2015-02-28 14:15:22 -03:00
Lucas De Marchi fae77516b4 build: we are kmod, not systemd
Fix copy and paste mistake.
2015-02-27 16:20:14 -03:00
Lucas De Marchi 16a62c7ab3 shared: avoid checking for __STDC_VERSION__
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.
2015-02-26 13:15:14 -03:00
Lucas De Marchi 481ad14550 build: simplify and organize configure
- 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
2015-02-26 12:21:08 -03:00
Lucas De Marchi a1bec0dfdb depmod: fix leak in case of malloc(0)
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.
2015-02-26 03:40:47 -03:00
Lucas De Marchi 0bcdef9700 build: add helpers to upload coverity tarball 2015-02-25 12:57:31 -03:00
Lucas De Marchi a07ea0329c depmod: use cleanup attribute to simplify free on exit
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".
2015-02-25 12:06:44 -03:00
Colin Walters 0b3aef23b8 depmod: Fix crash in previous commit if root is not set
[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.
2015-02-25 11:27:05 -03:00
Lucas De Marchi e90f0704ea depmod: fix leaking root on exit 2015-02-25 00:50:37 -03:00
David Herrmann 29ad07504b from systemd: build: make sure to test for -Wflag instead of -Wno-flag
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.
2015-02-24 22:45:17 -03:00
Zbigniew Jędrzejewski-Szmek a8f3aaebbe from systemd: build-sys: fix conftest.c to work on arm
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
2015-02-24 22:42:06 -03:00
David Herrmann 779729cf53 from systemd: build: check for build/link flags harder
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.
2015-02-24 22:41:30 -03:00
Lucas De Marchi c619d89208 from systemd: build: merge trivial changes back
These were trivial changes applied to systemd tree since the files were
synchronized:

  - change some comments
  - replace tab with space
  - fix typo
2015-02-24 22:37:27 -03:00
Lucas De Marchi 80f6ab5c9c build: add missing files to EXTRA_DIST
Fix make distcheck.
2015-02-24 01:50:32 -03:00
Lucas De Marchi 10d783c4a7 module-playground: don clean all .ko files
Rather than calling kernel's make for clean target, do it by ourselves.
This way we can preserve some prebuilt modules.
2015-02-24 01:48:48 -03:00
Marcus Meissner 0af8f786c0 testsuite: move test-blacklist to DEFINE_TEST
otherwise the test will not be executed.

Signed-Off-By: Marcus Meissner <meissner@suse.de>
2015-02-22 13:46:18 -03:00
Lucas De Marchi 3f0eb43b6d testsuite: port signature-check modules to module-playground
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.
2015-02-21 15:51:42 -02:00
Lucas De Marchi 77fdc66429 testsuite: port arch-specific tests to module-playground
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.
2015-02-21 15:09:12 -02:00
Lucas De Marchi a24e17839c fixup! module-playground: allow to cross-compile modules 2015-02-21 15:08:19 -02:00
Lucas De Marchi 5eafc34d66 testsuite: leave arch-specific modules in tree
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.
2015-02-21 15:05:25 -02:00
Lucas De Marchi f6dc239ed2 testsuite: add option to copy output from test
This is helpful while debugging the tests: copy the output from test
(both stdout and stderr) to the stdout of the parent process.
2015-02-21 13:39:36 -02:00
Lucas De Marchi 03a5079f62 testsuite: fix exiting with success on no output activity
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.
2015-02-21 13:15:38 -02:00
Lucas De Marchi 7efa3502dd module-playground: allow to cross-compile modules
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.
2015-02-21 11:40:27 -02:00
Lucas De Marchi 2a38870e3d testsuite: port modules-order-compressed to module-playground 2015-02-19 19:50:16 -02:00
Lucas De Marchi 709a465d0e Update TODO 2015-02-19 01:00:05 -02:00
Lucas De Marchi 885e90b6f9 libkmod: better explain a signed module layout 2015-02-18 16:49:01 -02:00
Lucas De Marchi dcbe1846e8 libkmod: consider empty signature key as invalid
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.
2015-02-18 16:15:45 -02:00
Tobias Stoeckmann 40ef6e69bb Fix out of bounds signature access with 32 bit off_t
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. ;)
2015-02-18 15:49:10 -02:00