]> git.ipfire.org Git - thirdparty/kmod.git/log
thirdparty/kmod.git
7 years agokmod 23 v23
Lucas De Marchi [Wed, 20 Jul 2016 04:38:42 +0000 (01:38 -0300)] 
kmod 23

7 years agoNEWS: add items for kmod 23
Lucas De Marchi [Tue, 28 Jun 2016 18:28:47 +0000 (15:28 -0300)] 
NEWS: add items for kmod 23

7 years agolibkmod: fix integration with gtk-doc
Lucas De Marchi [Tue, 28 Jun 2016 15:14:38 +0000 (12:14 -0300)] 
libkmod: fix integration with gtk-doc

It was failing to generate doc with recent version of gtk-doc

[kmod]$ ./bootstrap
libkmod/docs/gtk-doc.make:33: error: EXTRA_DIST must be set with '=' before using '+='
libkmod/docs/Makefile.am:29:   'libkmod/docs/gtk-doc.make' included from here
autoreconf: automake failed with exit status: 1

Just add an empty EXTRA_DIST so it works.

7 years agolibkmod-module: modinfo: print signature id
Lucas De Marchi [Sun, 5 Jun 2016 03:09:22 +0000 (00:09 -0300)] 
libkmod-module: modinfo: print signature id

This way it's possible to give at least the signature type for PKCS#7.

7 years agolibkmod-signature: handle PKCS#7
Lucas De Marchi [Sun, 5 Jun 2016 03:00:57 +0000 (00:00 -0300)] 
libkmod-signature: handle PKCS#7

7 years agolibkmod-module: do not crash modinfo on 0 key id len
Lucas De Marchi [Sun, 5 Jun 2016 01:37:11 +0000 (22:37 -0300)] 
libkmod-module: do not crash modinfo on 0 key id len

7 years agolibkmod: Handle long lines in /proc/modules
Michal Marek [Fri, 17 Jun 2016 14:04:15 +0000 (16:04 +0200)] 
libkmod: Handle long lines in /proc/modules

kmod_module_new_from_loaded() calls fgets with a 4k buffer. When a
module such as usbcore is used by too many modules, the rest of the line
is considered a beginning of another lines and we eventually get errors
like these from lsmod:

libkmod: kmod_module_get_holders: could not open '/sys/module/100,/holders': No such file or directory

together with bogus entries in the output. In kmod_module_get_size, the
problem does not affect functionality, but the line numbers in error
messages will be wrong.

Signed-off-by: Michal Marek <mmarek@suse.com>
7 years agodepmod: Ignore PowerPC64 ABIv2 .TOC. symbol
Anton Blanchard [Fri, 10 Jun 2016 05:24:30 +0000 (15:24 +1000)] 
depmod: Ignore PowerPC64 ABIv2 .TOC. symbol

The .TOC. symbol on the PowerPC64 ABIv2 identifies the GOT
pointer, similar to how other architectures use _GLOBAL_OFFSET_TABLE_.

This is not a symbol that needs relocation, and should be ignored
by depmod.

7 years agoREADME: add link to patchwork
Lucas De Marchi [Tue, 24 May 2016 14:45:25 +0000 (11:45 -0300)] 
README: add link to patchwork

7 years agokmod: compiling with old sed version (!ERE support)
Héctor Orón Martínez [Mon, 2 May 2016 14:38:24 +0000 (16:38 +0200)] 
kmod: compiling with old sed version (!ERE support)

  Makefile.am uses `sed -E', which it is found on BSD sed; however a
  replacement on GNU sed would be `sed -r'. Both intend to use extended
  regular expressions (ERE). However I have a system that does not support
  those, in benefit for portability could you consider replacing ERE by BRE.

Signed-off-by: Héctor Orón Martínez <hector.oron@gmail.com>
7 years agokmod_module_get_refcnt: fix documentation
Peter Wu [Sat, 21 May 2016 11:15:19 +0000 (13:15 +0200)] 
kmod_module_get_refcnt: fix documentation

8 years agotravis: workaround bug in environment setup
Lucas De Marchi [Mon, 11 Jan 2016 12:48:33 +0000 (10:48 -0200)] 
travis: workaround bug in environment setup

Travis is poluting the environment, particularly PYTHON_CFLAGS which
makes the build to fail. Just unset the variable since we don't want to
override these cflags.

8 years agodepmod: Don't insert comment in modules.devname if otherwise empty
Josh Triplett [Sun, 10 Jan 2016 15:10:25 +0000 (07:10 -0800)] 
depmod: Don't insert comment in modules.devname if otherwise empty

This allows tools to detect the file as empty, such as via systemd's
ConditionFileNotEmpty.

8 years agoinsmod: fix wron fallthrough of -f
Marc-Antoine Perennou [Fri, 20 Nov 2015 21:23:14 +0000 (22:23 +0100)] 
insmod: fix wron fallthrough of -f

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
8 years agokmod 22 v22
Lucas De Marchi [Wed, 18 Nov 2015 00:12:07 +0000 (22:12 -0200)] 
kmod 22

8 years agoinsmod: do support -f
Philippe De Swert [Wed, 7 Oct 2015 15:36:58 +0000 (18:36 +0300)] 
insmod: do support -f

The -f switch is accepted by insmod, but silently ignored. This
causes the user to wonder why things don't work. As insmod is
most often used with "evil" modules, -f is almost default and
thus needs to work.

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
8 years agolibkmod: export new kmod_get_dirname() function
Lucas De Marchi [Wed, 30 Sep 2015 18:28:24 +0000 (15:28 -0300)] 
libkmod: export new kmod_get_dirname() function

Make sure it gets exported and add documentation.

8 years agodepmod: Don't fall back to uname on bad version
Laura Abbott [Mon, 28 Sep 2015 22:39:14 +0000 (15:39 -0700)] 
depmod: Don't fall back to uname on bad version

Currently, if a value that doesn't match a kernel version
("%u.%u") is passed in, depmod silently falls back to
using uname. Rather than try and work around the caller passing
bad data, just exit out instead.

8 years agodepmod: Remove unprinted debug messages
Laura Abbott [Mon, 28 Sep 2015 22:39:13 +0000 (15:39 -0700)] 
depmod: Remove unprinted debug messages

In between the start of the program and the call to log_setup_kmod_log,
the only messages that will be printed are the ones at or above the
global default level. Debug messages in this range will never be printed
so remove them.

8 years agoChange default log level
Laura Abbott [Mon, 28 Sep 2015 22:39:12 +0000 (15:39 -0700)] 
Change default log level

The default log level is currently LOG_ERR. Tools can override this
default but there is a non-trivial amount of setup that needs to
happen before the log level can be changed. Since tools may want to
use the warn level for things such as deprecated flags, change the
default to LOG_WARNING to ensure messages get printed.

8 years agomodprobe: Update error message when path is missing
Laura Abbott [Mon, 28 Sep 2015 22:39:11 +0000 (15:39 -0700)] 
modprobe: Update error message when path is missing

Currently, modprobe fails with no output by default if the
search paths it tries are missing:

$ modprobe -S notakernel dm-crypt
$
$ modprobe -S notakernel lkjjweiojo
$

This is fairly cryptic and not at all obvious there is a problem
unless the error code is checked or verbose flags are used.
Update the error message to indicate a problem and print out the
directory that failed.

8 years agoREADME: Indicate cython requirements
Laura Abbott [Mon, 28 Sep 2015 22:39:10 +0000 (15:39 -0700)] 
README: Indicate cython requirements

The recommended flags require cython be installed to compile
successfully. Note this in the documentation.

8 years agobuild: let sed use posix ERE instead of GNU extension
Natanael Copa [Mon, 22 Jun 2015 12:09:17 +0000 (14:09 +0200)] 
build: let sed use posix ERE instead of GNU extension

Use POSIX Extended Regular Expression (ERE) instead of the GNU extension
\| in the install-exec-hook. This makes it create the symlink properly
with busybox sed built with musl libc. It will silently create a broken
symlink otherwise.

Lucas De Marchi:  fix up added newline.

8 years agolibkmod-module: fix return code in error path
Lucas De Marchi [Sat, 13 Jun 2015 21:29:47 +0000 (18:29 -0300)] 
libkmod-module: fix return code in error path

ENOSYS is the wrong errno to return when we don't find a module in
kmod_module_insert_module(). Why is it there in the first place?  This
goes back to kmod v1 when we couldn't load modules by names, but we
should give a path instead.

708624a ("ELF: initial support for modinfo and strip of modversions and
vermagic.") changed that so we do a lazy-search by the module path in
this function. Later  f304afe ("Change error message to reflect
reality") fixed the log message but the return coded remained the same.

8 years agoAdd README.md file with build details
Lucas De Marchi [Thu, 11 Jun 2015 16:59:54 +0000 (13:59 -0300)] 
Add README.md file with build details

Add the badges from semaphoreci and coverity and point people to the
README file with more information.

8 years agokmod 21 v21
Lucas De Marchi [Tue, 9 Jun 2015 05:36:14 +0000 (02:36 -0300)] 
kmod 21

8 years agobuild: add cache to distributed files
Lucas De Marchi [Tue, 9 Jun 2015 05:03:36 +0000 (02:03 -0300)] 
build: add cache to distributed files

We were missing the cache directory on the distributed files.

8 years agobuild: silence stderr on coverity rules
Lucas De Marchi [Tue, 9 Jun 2015 05:01:11 +0000 (02:01 -0300)] 
build: silence stderr on coverity rules

We try to execute git in order to get the dependencies for the coverity
rules. And it gets executed even when we are not calling that specific
rule.  Later we may want to improve it, but for now let's just silence
the errors of not being a git repository when executing this on a
packaged version.

8 years agokmod: fix small typo in rmmod(8)
Santiago Vila [Tue, 9 Jun 2015 01:46:42 +0000 (22:46 -0300)] 
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)

8 years agotools: display features in --version
Lucas De Marchi [Sun, 7 Jun 2015 05:46:22 +0000 (02:46 -0300)] 
tools: display features in --version

Reviewed-by: Andreas Mohr <andim2@users.sf.net>
8 years agobuild: add relevant features to KMOD_FEATURES in config.h
Lucas De Marchi [Sun, 7 Jun 2015 05:44:02 +0000 (02:44 -0300)] 
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>
8 years agobuild: add function to build string of features
Lucas De Marchi [Sun, 7 Jun 2015 04:15:30 +0000 (01:15 -0300)] 
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>
8 years agotools: add PACKAGE definition in message
Lucas De Marchi [Tue, 9 Jun 2015 00:30:11 +0000 (21:30 -0300)] 
tools: add PACKAGE definition in message

Reported-by: Andreas Mohr <andim2@users.sf.net>
8 years agotools: Hide new commands behind experimental flag
Lucas De Marchi [Sun, 7 Jun 2015 02:26:31 +0000 (23:26 -0300)] 
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.

8 years agobuild: cache modules from playground
Lucas De Marchi [Sun, 31 May 2015 18:38:47 +0000 (15:38 -0300)] 
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.

9 years agoFix spurious spaces in lsmod output
Santiago Vila [Thu, 16 Apr 2015 11:44:22 +0000 (08:44 -0300)] 
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.

9 years agoutil: use UINT64_MAX
Lucas De Marchi [Tue, 24 Mar 2015 02:47:23 +0000 (23:47 -0300)] 
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.

9 years agobuild: sync dolt with upstream
Lucas De Marchi [Tue, 10 Mar 2015 18:17:03 +0000 (15:17 -0300)] 
build: sync dolt with upstream

9 years agotools: add basic versions of insert and remove
Caio Marcelo de Oliveira Filho [Sat, 7 Mar 2015 13:32:53 +0000 (10:32 -0300)] 
tools: add basic versions of insert and remove

9 years agotestsuite: update README
Caio Marcelo de Oliveira Filho [Thu, 5 Mar 2015 16:06:38 +0000 (13:06 -0300)] 
testsuite: update README

9 years agotestsuite: remove .gitignore files when populating rootfs
Caio Marcelo de Oliveira Filho [Thu, 5 Mar 2015 16:06:37 +0000 (13:06 -0300)] 
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.

9 years agobuild: use dolt
Lucas De Marchi [Thu, 5 Mar 2015 16:03:35 +0000 (13:03 -0300)] 
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

9 years agokmod 20 v20
Lucas De Marchi [Sun, 1 Mar 2015 17:43:09 +0000 (14:43 -0300)] 
kmod 20

9 years agoUpdate TODO
Lucas De Marchi [Sun, 1 Mar 2015 17:16:59 +0000 (14:16 -0300)] 
Update TODO

9 years agoCheck return of fseek while reading index
Lucas De Marchi [Sat, 28 Feb 2015 19:11:53 +0000 (16:11 -0300)] 
Check return of fseek while reading index

9 years agoAvoid sign-extension error on multiplication
Lucas De Marchi [Sat, 28 Feb 2015 19:07:55 +0000 (16:07 -0300)] 
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.

9 years agodepmod: add asserts to ensure positive return from ftell()
Lucas De Marchi [Sat, 28 Feb 2015 17:45:07 +0000 (14:45 -0300)] 
depmod: add asserts to ensure positive return from ftell()

Also ignore some errors that will later be returned by ferror().

9 years agotestsuite: add test for modprobe -R <builtin-module>
Lucas De Marchi [Fri, 27 Feb 2015 18:46:24 +0000 (15:46 -0300)] 
testsuite: add test for modprobe -R <builtin-module>

9 years agomodprobe: stop checking initstate for builtin modules
Lucas De Marchi [Fri, 27 Feb 2015 18:39:36 +0000 (15:39 -0300)] 
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.

9 years agotestsuite: test builtin state
Lucas De Marchi [Fri, 27 Feb 2015 04:51:45 +0000 (01:51 -0300)] 
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)

9 years agoFix race while loading modules
Harish Jenny K N [Sun, 22 Feb 2015 18:41:07 +0000 (15:41 -0300)] 
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.  ]

9 years agobuild: we are kmod, not systemd
Lucas De Marchi [Fri, 27 Feb 2015 19:19:44 +0000 (16:19 -0300)] 
build: we are kmod, not systemd

Fix copy and paste mistake.

9 years agoshared: avoid checking for __STDC_VERSION__
Lucas De Marchi [Thu, 26 Feb 2015 16:02:04 +0000 (13:02 -0300)] 
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.

9 years agobuild: simplify and organize configure
Lucas De Marchi [Thu, 26 Feb 2015 05:56:04 +0000 (02:56 -0300)] 
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

9 years agodepmod: fix leak in case of malloc(0)
Lucas De Marchi [Thu, 26 Feb 2015 06:38:52 +0000 (03:38 -0300)] 
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.

9 years agobuild: add helpers to upload coverity tarball
Lucas De Marchi [Wed, 25 Feb 2015 15:45:02 +0000 (12:45 -0300)] 
build: add helpers to upload coverity tarball

9 years agodepmod: use cleanup attribute to simplify free on exit
Lucas De Marchi [Wed, 25 Feb 2015 15:06:44 +0000 (12:06 -0300)] 
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".

9 years agodepmod: Fix crash in previous commit if root is not set
Colin Walters [Wed, 25 Feb 2015 13:22:38 +0000 (08:22 -0500)] 
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.

9 years agodepmod: fix leaking root on exit
Lucas De Marchi [Wed, 25 Feb 2015 02:58:39 +0000 (23:58 -0300)] 
depmod: fix leaking root on exit

9 years agofrom systemd: build: make sure to test for -Wflag instead of -Wno-flag
David Herrmann [Tue, 24 Feb 2015 16:49:48 +0000 (17:49 +0100)] 
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.

9 years agofrom systemd: build-sys: fix conftest.c to work on arm
Zbigniew Jędrzejewski-Szmek [Sun, 3 Aug 2014 03:50:22 +0000 (23:50 -0400)] 
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

9 years agofrom systemd: build: check for build/link flags harder
David Herrmann [Fri, 13 Sep 2013 10:42:12 +0000 (12:42 +0200)] 
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.

9 years agofrom systemd: build: merge trivial changes back
Lucas De Marchi [Wed, 25 Feb 2015 01:29:04 +0000 (22:29 -0300)] 
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

9 years agobuild: add missing files to EXTRA_DIST
Lucas De Marchi [Tue, 24 Feb 2015 04:50:32 +0000 (01:50 -0300)] 
build: add missing files to EXTRA_DIST

Fix make distcheck.

9 years agomodule-playground: don clean all .ko files
Lucas De Marchi [Tue, 24 Feb 2015 04:48:48 +0000 (01:48 -0300)] 
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.

9 years agotestsuite: move test-blacklist to DEFINE_TEST
Marcus Meissner [Sun, 22 Feb 2015 10:48:13 +0000 (11:48 +0100)] 
testsuite: move test-blacklist to DEFINE_TEST

otherwise the test will not be executed.

Signed-Off-By: Marcus Meissner <meissner@suse.de>
9 years agotestsuite: port signature-check modules to module-playground
Lucas De Marchi [Sat, 21 Feb 2015 17:47:16 +0000 (15:47 -0200)] 
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.

9 years agotestsuite: port arch-specific tests to module-playground
Lucas De Marchi [Sat, 21 Feb 2015 17:09:12 +0000 (15:09 -0200)] 
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.

9 years agofixup! module-playground: allow to cross-compile modules
Lucas De Marchi [Sat, 21 Feb 2015 17:08:19 +0000 (15:08 -0200)] 
fixup! module-playground: allow to cross-compile modules

9 years agotestsuite: leave arch-specific modules in tree
Lucas De Marchi [Sat, 21 Feb 2015 17:02:55 +0000 (15:02 -0200)] 
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.

9 years agotestsuite: add option to copy output from test
Lucas De Marchi [Sat, 21 Feb 2015 15:39:36 +0000 (13:39 -0200)] 
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.

9 years agotestsuite: fix exiting with success on no output activity
Lucas De Marchi [Sat, 21 Feb 2015 15:07:42 +0000 (13:07 -0200)] 
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.

9 years agomodule-playground: allow to cross-compile modules
Lucas De Marchi [Sat, 21 Feb 2015 05:22:54 +0000 (03:22 -0200)] 
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.

9 years agotestsuite: port modules-order-compressed to module-playground
Lucas De Marchi [Thu, 19 Feb 2015 21:50:16 +0000 (19:50 -0200)] 
testsuite: port modules-order-compressed to module-playground

9 years agoUpdate TODO
Lucas De Marchi [Thu, 19 Feb 2015 03:00:05 +0000 (01:00 -0200)] 
Update TODO

9 years agolibkmod: better explain a signed module layout
Lucas De Marchi [Wed, 18 Feb 2015 18:47:14 +0000 (16:47 -0200)] 
libkmod: better explain a signed module layout

9 years agolibkmod: consider empty signature key as invalid
Lucas De Marchi [Wed, 18 Feb 2015 18:15:45 +0000 (16:15 -0200)] 
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.

9 years agoFix out of bounds signature access with 32 bit off_t
Tobias Stoeckmann [Sat, 14 Feb 2015 23:35:47 +0000 (00:35 +0100)] 
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. ;)

9 years agolibkmod: properly validate file size
Tobias Stoeckmann [Tue, 10 Feb 2015 18:46:40 +0000 (19:46 +0100)] 
libkmod: properly validate file size

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.

9 years agotestsuite: port kcmdline test to module-playground
Lucas De Marchi [Wed, 11 Feb 2015 04:59:08 +0000 (02:59 -0200)] 
testsuite: port kcmdline test to module-playground

9 years agotestsuite: port install-cmd-loop test to module-playground
Lucas De Marchi [Wed, 11 Feb 2015 04:50:06 +0000 (02:50 -0200)] 
testsuite: port install-cmd-loop test to module-playground

9 years agotestsuite: port alias-to-none test to module-playground
Lucas De Marchi [Wed, 11 Feb 2015 00:19:53 +0000 (22:19 -0200)] 
testsuite: port alias-to-none test to module-playground

9 years agotestsuite: port tests without finit_module() to module-playground
Lucas De Marchi [Wed, 11 Feb 2015 00:11:25 +0000 (22:11 -0200)] 
testsuite: port tests without finit_module() to module-playground

9 years agotestsuite: port modprobe --force test to module-playground
Lucas De Marchi [Wed, 11 Feb 2015 00:01:42 +0000 (22:01 -0200)] 
testsuite: port modprobe --force test to module-playground

9 years agotestsuite: port softdep-loop test to module-playground
Lucas De Marchi [Tue, 10 Feb 2015 23:45:09 +0000 (21:45 -0200)] 
testsuite: port softdep-loop test to module-playground

9 years agolibkmod: use helper function to check for overflow
Lucas De Marchi [Tue, 10 Feb 2015 12:46:26 +0000 (10:46 -0200)] 
libkmod: use helper function to check for overflow

9 years agoshared: add helper function to add and check for overflow
Lucas De Marchi [Tue, 10 Feb 2015 12:41:47 +0000 (10:41 -0200)] 
shared: add helper function to add and check for overflow

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.

9 years agobuild: define to 0 if builtin is not available
Lucas De Marchi [Tue, 10 Feb 2015 12:32:10 +0000 (10:32 -0200)] 
build: define to 0 if builtin is not available

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.

9 years agoPrevent offset + size overflow.
Tobias Stoeckmann [Mon, 9 Feb 2015 22:22:51 +0000 (23:22 +0100)] 
Prevent offset + size overflow.

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.

9 years agotestsuite: port show-depends tests to module-playground
Lucas De Marchi [Tue, 10 Feb 2015 11:30:49 +0000 (09:30 -0200)] 
testsuite: port show-depends tests to module-playground

Another test, modprobe_show_alias_to_none was wrongly checking the
output in the show-depends namespace so it needed changing as well.

9 years agobuild: check for required builtin functions
Lucas De Marchi [Tue, 10 Feb 2015 02:45:11 +0000 (00:45 -0200)] 
build: check for required builtin functions

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.

9 years agobuild: add better check for builtin function
Lucas De Marchi [Tue, 10 Feb 2015 02:31:08 +0000 (00:31 -0200)] 
build: add better check for builtin function

It's not used right now in kmod, but may be used in future for other
builtins, so let the macro generic.

9 years agotestsuite: port detect-loop test to module-playground
Lucas De Marchi [Mon, 9 Feb 2015 16:07:31 +0000 (14:07 -0200)] 
testsuite: port detect-loop test to module-playground

9 years agotravis: also test with gcc 4.8 and 4.9
Lucas De Marchi [Wed, 4 Feb 2015 07:44:04 +0000 (05:44 -0200)] 
travis: also test with gcc 4.8 and 4.9

9 years agotravis: use kernel headers for testsuite
Lucas De Marchi [Tue, 3 Feb 2015 03:21:11 +0000 (01:21 -0200)] 
travis: use kernel headers for testsuite

Install kernel headers and export KDIR variable to point to right dir.

9 years agotestsuite: convert test-init function to use mod-simple.ko
Lucas De Marchi [Tue, 3 Feb 2015 07:17:10 +0000 (05:17 -0200)] 
testsuite: convert test-init function to use mod-simple.ko

9 years agobuild: let touch on directory as last step
Lucas De Marchi [Tue, 3 Feb 2015 07:17:49 +0000 (05:17 -0200)] 
build: let touch on directory as last step

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.

9 years agotestsuite: port test-dependencies to module-playground
Lucas De Marchi [Tue, 3 Feb 2015 02:24:33 +0000 (00:24 -0200)] 
testsuite: port test-dependencies to module-playground

9 years agotestsuite: make test-dependencies use DEFINE_TEST
Lucas De Marchi [Tue, 3 Feb 2015 01:55:56 +0000 (23:55 -0200)] 
testsuite: make test-dependencies use DEFINE_TEST

It went missing from previous conversions.

9 years agotestsuite: use mod-simple.ko for search-order-same-prefix test
Lucas De Marchi [Tue, 3 Feb 2015 00:35:02 +0000 (22:35 -0200)] 
testsuite: use mod-simple.ko for search-order-same-prefix test