]> git.ipfire.org Git - thirdparty/kmod.git/log
thirdparty/kmod.git
6 years agokmod 25 v25
Lucas De Marchi [Tue, 9 Jan 2018 01:30:39 +0000 (17:30 -0800)] 
kmod 25

6 years agotestsuite: also wrap gettid in syscall()
Lucas De Marchi [Mon, 8 Jan 2018 16:22:29 +0000 (08:22 -0800)] 
testsuite: also wrap gettid in syscall()

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).

6 years agotestsuite: explain why overriding function may fail
Lucas De Marchi [Wed, 3 Jan 2018 22:14:06 +0000 (14:14 -0800)] 
testsuite: explain why overriding function may fail

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.

6 years agotestsuite: add missing error handling
Lucas De Marchi [Wed, 3 Jan 2018 21:37:59 +0000 (13:37 -0800)] 
testsuite: add missing error handling

If we passed an invalid argument to a test it would segfault rather than
returning an error code.

6 years agotestsuite: add Fedora's mkosi configuration
Lucas De Marchi [Wed, 3 Jan 2018 19:23:51 +0000 (11:23 -0800)] 
testsuite: add Fedora's mkosi configuration

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.

6 years agotestsuite: generalize mkosi support for other distros
Lucas De Marchi [Wed, 3 Jan 2018 19:19:02 +0000 (11:19 -0800)] 
testsuite: generalize mkosi support for other distros

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.

6 years agobuild: use tool from configure
Lucas De Marchi [Wed, 3 Jan 2018 02:17:51 +0000 (18:17 -0800)] 
build: use tool from configure

This way we make sure the tool will be the one we actually configured
before going through sudo.

6 years agobuild: add mkosi hooks
Lucas De Marchi [Tue, 2 Jan 2018 22:08:03 +0000 (14:08 -0800)] 
build: add mkosi hooks

Right now there's support for building on Archlinux only.

6 years agodepmod: module_is_higher_priority: fix modname length calculation
Yauheni Kaliuta [Thu, 7 Dec 2017 19:16:08 +0000 (21:16 +0200)] 
depmod: module_is_higher_priority: fix modname length calculation

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>
6 years agotestsuite: depmod: add override test
Yauheni Kaliuta [Thu, 7 Dec 2017 19:16:07 +0000 (21:16 +0200)] 
testsuite: depmod: add override test

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>
6 years agodepmod: Don't add .TOC. when it's in the kernel.
Michal Suchanek [Thu, 7 Dec 2017 14:31:19 +0000 (15:31 +0100)] 
depmod: Don't add .TOC. when it's in the kernel.

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>
6 years agoman/depmod: Add references in other man pages
Christopher Díaz Riveros [Mon, 16 Oct 2017 15:48:42 +0000 (10:48 -0500)] 
man/depmod: Add references in other man pages

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>
6 years agolibkmod-elf: resolve CRC if module is built with MODULE_REL_CRCS
Yauheni Kaliuta [Wed, 19 Jul 2017 14:56:49 +0000 (17:56 +0300)] 
libkmod-elf: resolve CRC if module is built with MODULE_REL_CRCS

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>
6 years agoman/depmod.d: add external keyword description
Yauheni Kaliuta [Thu, 20 Jul 2017 14:09:52 +0000 (17:09 +0300)] 
man/depmod.d: add external keyword description

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>
6 years agoshared/util.c: assert_cc() can only be used inside functions
Thomas Petazzoni [Sat, 3 Jun 2017 15:03:22 +0000 (17:03 +0200)] 
shared/util.c: assert_cc() can only be used inside functions

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>
6 years agotestsuite: add tests for external directory support
Yauheni Kaliuta [Tue, 9 May 2017 19:09:24 +0000 (22:09 +0300)] 
testsuite: add tests for external directory support

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>
6 years agodepmod: implement external directories support
Yauheni Kaliuta [Tue, 9 May 2017 19:09:23 +0000 (22:09 +0300)] 
depmod: implement external directories support

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>
6 years agotest-depmod: avoid warning when we don't have zlib
Lucas De Marchi [Fri, 2 Jun 2017 03:25:57 +0000 (20:25 -0700)] 
test-depmod: avoid warning when we don't have zlib

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)
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

6 years agodepmod: rewrite depmod modules search with scratchbuf
Yauheni Kaliuta [Tue, 9 May 2017 19:09:22 +0000 (22:09 +0300)] 
depmod: rewrite depmod modules search with scratchbuf

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>
6 years agodepmod: create depmod dir independent search function
Yauheni Kaliuta [Tue, 9 May 2017 19:09:21 +0000 (22:09 +0300)] 
depmod: create depmod dir independent search function

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>
6 years agodepmod: search key: move builtin detection under the add function
Yauheni Kaliuta [Wed, 23 Nov 2016 15:23:38 +0000 (17:23 +0200)] 
depmod: search key: move builtin detection under the add function

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>
6 years agodepmod: fix errorpath memleaks in report cycles logic
Yauheni Kaliuta [Mon, 20 Mar 2017 10:09:51 +0000 (12:09 +0200)] 
depmod: fix errorpath memleaks in report cycles logic

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>
7 years agolibkmod: modinfo: implement signature output
Yauheni Kaliuta [Tue, 11 Apr 2017 12:15:03 +0000 (15:15 +0300)] 
libkmod: modinfo: implement signature output

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>
7 years agolibkmod: modinfo: implement line splitting in hex_to_str
Yauheni Kaliuta [Tue, 11 Apr 2017 12:15:02 +0000 (15:15 +0300)] 
libkmod: modinfo: implement line splitting in hex_to_str

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>
7 years agolibkmod: modinfo: use own function for sig_key hex output
Yauheni Kaliuta [Tue, 11 Apr 2017 12:15:01 +0000 (15:15 +0300)] 
libkmod: modinfo: use own function for sig_key hex output

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>
7 years agolibkmod: modinfo: fix sig_id output
Yauheni Kaliuta [Tue, 11 Apr 2017 12:15:00 +0000 (15:15 +0300)] 
libkmod: modinfo: fix sig_id output

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>
7 years agokmod 24 v24
Lucas De Marchi [Fri, 24 Feb 2017 07:32:51 +0000 (23:32 -0800)] 
kmod 24

7 years agobuild: update autogen
Lucas De Marchi [Fri, 24 Feb 2017 05:58:15 +0000 (21:58 -0800)] 
build: update autogen

Bring new options from systemd and other projects.

7 years agodepmod: fix leak on error path
Lucas De Marchi [Fri, 24 Feb 2017 05:47:37 +0000 (21:47 -0800)] 
depmod: fix leak on error path

7 years agoman: make error message clearer for missing xstlproc
Lucas De Marchi [Fri, 24 Feb 2017 02:28:27 +0000 (18:28 -0800)] 
man: make error message clearer for missing xstlproc

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

7 years agobuild: add missing header
Lucas De Marchi [Fri, 24 Feb 2017 02:26:54 +0000 (18:26 -0800)] 
build: add missing header

Fix failing distcheck

7 years agodepmod: handle nested loops
Yauheni Kaliuta [Wed, 22 Feb 2017 09:41:59 +0000 (11:41 +0200)] 
depmod: handle nested loops

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>
7 years agotestsuite: depmod: check netsted loops reporting
Yauheni Kaliuta [Wed, 22 Feb 2017 09:41:58 +0000 (11:41 +0200)] 
testsuite: depmod: check netsted loops reporting

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>
7 years agolibkmod-config: fix parsing quoted kernel cmdline on params
Lucas De Marchi [Thu, 16 Feb 2017 17:18:35 +0000 (09:18 -0800)] 
libkmod-config: fix parsing quoted kernel cmdline on params

We can only accept quoted values, not module names or parameter names.

7 years agolibkmod-config: replace 0/1 with bool
Lucas De Marchi [Thu, 16 Feb 2017 16:57:01 +0000 (08:57 -0800)] 
libkmod-config: replace 0/1 with bool

7 years agomodule: fix a memory leak
Bartosz Golaszewski [Wed, 15 Feb 2017 11:18:03 +0000 (12:18 +0100)] 
module: fix a memory leak

When a module is removed and re-inserted without unrefing, the
kmod_file is unconditionally re-opened. This results in a memory
and file descriptor leak.

Fix it by checking if the file is already open in
kmod_module_insert_module().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
7 years agotestsuite: add test for kernel cmdline with quotes
Lucas De Marchi [Mon, 23 Jan 2017 19:59:31 +0000 (11:59 -0800)] 
testsuite: add test for kernel cmdline with quotes

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.

7 years agotestsuite: fix typo in description
Lucas De Marchi [Mon, 23 Jan 2017 19:58:29 +0000 (11:58 -0800)] 
testsuite: fix typo in description

7 years agolibkmod: Fix handling of quotes in kernel command line
James Minor [Fri, 20 Jan 2017 23:15:50 +0000 (17:15 -0600)] 
libkmod: Fix handling of quotes in kernel command line

If a module parameter on the command line contains quotes, any
spaces inside those quotes should be included as part of the
parameter.

Signed-off-by: James Minor <james.minor@ni.com>
7 years agobuild: fix build with disabled test modules
Lucas De Marchi [Fri, 11 Nov 2016 01:37:04 +0000 (23:37 -0200)] 
build: fix build with disabled test modules

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.

7 years agoshared: make scratchbuf_str static
Yauheni Kaliuta [Wed, 9 Nov 2016 06:52:26 +0000 (08:52 +0200)] 
shared: make scratchbuf_str static

It fixes linking problem

tools/depmod.o: In function `output_symbols_bin':
depmod.c:(.text.output_symbols_bin+0x135): undefined reference to `scratchbuf_str'

for -O0 build, where gcc doesn't actually inline it.

Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
7 years agodepmod: ignore related modules in depmod_report_cycles
Mian Yousaf Kaukab [Tue, 8 Nov 2016 16:45:50 +0000 (17:45 +0100)] 
depmod: ignore related modules in depmod_report_cycles

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>
7 years agotestsuite: depmod: add module dependency outside cyclic chain
Mian Yousaf Kaukab [Tue, 8 Nov 2016 16:45:49 +0000 (17:45 +0100)] 
testsuite: depmod: add module dependency outside cyclic chain

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>
7 years agotestsuite: fix test_array_sort pointers inderection
Yauheni Kaliuta [Tue, 8 Nov 2016 20:57:26 +0000 (22:57 +0200)] 
testsuite: fix test_array_sort pointers inderection

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>
7 years agodepmod: fix string overflow
Lucas De Marchi [Wed, 10 Aug 2016 18:33:18 +0000 (15:33 -0300)] 
depmod: fix string overflow

Use scratchbuf to fix issue with strcpy that may overflow the buffer we
declared in the stack.

7 years agoAdd scratchbuf implementation
Lucas De Marchi [Wed, 10 Aug 2016 17:20:32 +0000 (14:20 -0300)] 
Add scratchbuf implementation

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"

7 years agotestsuite: include stdio.h
Lucas De Marchi [Wed, 10 Aug 2016 17:51:57 +0000 (14:51 -0300)] 
testsuite: include stdio.h

It's used in the log macros so include it.

7 years agoutil: fix warning of equal values on logical OR
Lucas De Marchi [Wed, 10 Aug 2016 15:42:12 +0000 (12:42 -0300)] 
util: fix warning of equal values on logical OR

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.

7 years agolibkmod: fix use of strcpy
Lucas De Marchi [Mon, 8 Aug 2016 14:42:52 +0000 (11:42 -0300)] 
libkmod: fix use of strcpy

We were not checking if there was sufficient space in the buffer.

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.  ]