Yauheni Kaliuta [Sun, 29 Nov 2020 16:47:35 +0000 (18:47 +0200)]
libkmod: kmod_builtin_get_modinfo: free modinfo on error
The function allocates array but on building it if get_string()
fails it returns the error leaving the array allocated. The caller
does not care about it in error case either.
Free it to fix memory leak.
Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Samanta Navarro [Sun, 4 Oct 2020 11:43:33 +0000 (11:43 +0000)]
man: fix typo
Torge Matthies [Tue, 8 Sep 2020 19:59:21 +0000 (21:59 +0200)]
testsuite: add test for zstd-compressed module
I took away one module from the gzip-compressed modules for this purpose.
Signed-off-by: Torge Matthies <openglfreak@googlemail.com>
Torge Matthies [Tue, 8 Sep 2020 19:59:20 +0000 (21:59 +0200)]
add Zstandard compression support
I changed the style of the hackargs variable in autogen.sh to multiline
because said line was becoming a bit long with the new --with-zstd arg
added.
A previous version of this patch has been running on my two Arch Linux
installations (with an accompanying mkinitcpio patch) for several months
over many kernel updates without any issues.
Any additional testing and/or patch review would of course be appreciated.
Signed-off-by: Torge Matthies <openglfreak@googlemail.com>
Lucas De Marchi [Tue, 10 Mar 2020 05:00:29 +0000 (22:00 -0700)]
testsuite: add check for kmod_load_resources
Make sure we can call kmod_load_resources when we do have all the
mandatory indexes in place.
Lucas De Marchi [Tue, 10 Mar 2020 05:00:28 +0000 (22:00 -0700)]
libkmod: allow modules.alias.builtin to be optional
Lucas De Marchi [Tue, 10 Mar 2020 05:00:27 +0000 (22:00 -0700)]
libkmod: fix return error when opening index
When calling kmod_load_resources() we could end up getting a bogus
return value -ENOMEM due to several other reasons, like the index not
existing. Change index_mm_open() to propagate the failure reason so we
can take actions on it or return to the caller.
Lucas De Marchi [Tue, 10 Mar 2020 05:00:26 +0000 (22:00 -0700)]
libkmod: simplify lookup when builtin.modinfo.bin file is missing
When we try to lookup a module and builtin.modinfo.bin is missing, we
would do the right thing because the caller was replacing the return
code with 0 (and the list was not modified).
Make it simpler by allowing the caller to check and differentiate the
errors between module not found and index not found.
Lucas De Marchi [Thu, 5 Mar 2020 21:33:10 +0000 (13:33 -0800)]
depmod: do not output .bin to stdout
index_write() relies on fseek/ftell to manage the position to which we
are write and thus needs the file stream to support it.
Right now when trying to write the index to stdout we fail with:
depmod: tools/depmod.c:416: index_write: Assertion `initial_offset >= 0' failed.
Aborted (core dumped)
We have no interest in outputting our index to stdout, so just skip it
like is done with other indexes.
While at it, add/remove some newlines to improve readability.
Reported-by: Yanko Kaneti <yaneti@declera.com>
Fix:
b866b2165ae6 ("Lookup aliases in the modules.builtin.modinfo")
Lucas De Marchi [Tue, 10 Mar 2020 08:17:12 +0000 (01:17 -0700)]
testsuite: check for ill-formed kcmdline
Commit
ca3bf5d47cec ("iommu/amd: Introduces ivrs_acpihid kernel parameter")
in the kernel introduced an ill-formed kernel parameter, ivrs_acpihid.
The problem is that it may have a dot on the key side:
"ivrs_acpihid[00:14.5]=AMD0020:0". This could potentially trip our
parser of module options, but right now it's working as intended: the
only thing that happens is that after deciding "ivrs_acpihid[00:14" is a
module name, it will fail the underscores() routine and the option will
be ignored from the kmod pov (not kernel's pov since that driver parsers
the kernel command line by itself).
Lucas De Marchi [Tue, 10 Mar 2020 08:06:39 +0000 (01:06 -0700)]
libkmod: ignore kcmdline option if we fail to parse modname
The error message is saying we are ignoring the option on the kernel
command line, so just do it.
Lucas De Marchi [Tue, 10 Mar 2020 04:46:32 +0000 (21:46 -0700)]
gitignore: ignore .cache.mk when building modules
Lucas De Marchi [Fri, 28 Feb 2020 20:53:47 +0000 (12:53 -0800)]
gitignore: ignore release files
Lucas De Marchi [Tue, 18 Feb 2020 23:54:07 +0000 (15:54 -0800)]
kmod 27
Lucas De Marchi [Mon, 20 Jan 2020 19:15:38 +0000 (16:15 -0300)]
libkmod: reset was_space on second pass
The softdep config parser uses a 2-pass approach to use a single
allocation for all the softdep struct. However "was_space" variable
isn't reset between them. This can lead to a buffer overflow.
Reported-by: Jorge Lucangeli Obes <jorgelo@google.com>
Link: https://lore.kernel.org/linux-modules/CAKYuF5QhGCPCazHQjN-=kFc5kHs7Ok8WqmmGLo31CiOEN8TYdA@mail.gmail.com
Topi Miettinen [Mon, 23 Dec 2019 16:58:13 +0000 (18:58 +0200)]
libkmod-module: convert return value from system() to errno
Don't use exit status of a command directly as errno code, callers
will be confused.
Signed-off-by: Topi Miettinen <toiwoton@gmail.com>
Alexey Gladkov [Fri, 8 Nov 2019 17:25:23 +0000 (18:25 +0100)]
modinfo: Show information about built-in modules
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
Alexey Gladkov [Fri, 8 Nov 2019 17:25:22 +0000 (18:25 +0100)]
Lookup aliases in the modules.builtin.modinfo
New modules.builtin.modinfo duplicates modules.builtin in the built-in
module name search. If it exists, then we can use this file, but if not,
then we need to fallback to the old file.
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
Alexey Gladkov [Fri, 8 Nov 2019 17:25:21 +0000 (18:25 +0100)]
libkmod: Add function to get list of built-in modules
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
Alexey Gladkov [Fri, 8 Nov 2019 17:25:20 +0000 (18:25 +0100)]
libkmod: Add parser for modules.builtin.modinfo
The kernel since version v5.2-rc1 exports information about built-in
modules in the modules.builtin.modinfo. Information is stored in
the same format as in the separate modules (null-terminated string
array). The module name is a prefix for each line.
$ tr '\0' '\n' < modules.builtin.modinfo
ext4.softdep=pre: crc32c
ext4.license=GPL
ext4.description=Fourth Extended Filesystem
ext4.author=Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others
ext4.alias=fs-ext4
ext4.alias=ext3
ext4.alias=fs-ext3
ext4.alias=ext2
ext4.alias=fs-ext2
md_mod.alias=block-major-9-*
md_mod.alias=md
md_mod.description=MD RAID framework
md_mod.license=GPL
md_mod.parmtype=create_on_open:bool
md_mod.parmtype=start_dirty_degraded:int
...
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
Fabrice Fontaine [Mon, 18 Nov 2019 21:56:17 +0000 (22:56 +0100)]
Makefile.am: filter -Wl,--no-undefined
Commit
1d14ef82f4a3be741bcdf6b1c6d51ce9dce43567 does not completely fix
the build with python 3.8 as we still get link failure due to
'-z undefs' being ignored by some versions of ld.
Indeed, -z undefs was added by commit
97a232d7335f3bd0231fd9cd39455bde1d563922 in upstream binutils, and this
commit was first present in binutils 2.30.
So any toolchain using binutils version older than that won't have
-z undefs and will build fail on:
/home/buildroot/autobuild/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/mips-linux-gnu/5.3.0/../../../../mips-linux-gnu/bin/ld: warning: -z undefs ignored.
/home/naourr/work/instance-1/output-1/host/opt/ext-toolchain/bin/../lib/gcc/aarch64_be-linux-gnu/7.3.1/../../../../aarch64_be-linux-gnu/bin/ld: warning: -z undefs ignored.
So filter -Wl,--no-undefined to fix the issue
Fixes:
- http://autobuild.buildroot.org/results/
e9645d9969481b09f507f6e0d0b35faaa283eb60
- http://autobuild.buildroot.org/results/
06a6d865b6b7d8ebd793bde214f4a4c40e0962e1
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Lucas De Marchi [Thu, 7 Nov 2019 07:27:28 +0000 (23:27 -0800)]
modprobe: use flags rather than bool args
It's easier to know what the caller is doing when we pass a named
flag rather than a list of bools.
Lucas De Marchi [Thu, 7 Nov 2019 16:34:15 +0000 (08:34 -0800)]
travis: remove old compiler failing to build kernel module
This is when building the kernel modules for testsuite:
Makefile:718: Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-protector-strong not supported by compiler
gcc: error: unrecognized command line option ‘-fstack-protector-strong’
Just drop gcc 4.8 from running tests. Failure not really related to kmod.
Lucas De Marchi [Thu, 7 Nov 2019 07:30:16 +0000 (23:30 -0800)]
testsuite: update gitignore
Yauheni Kaliuta [Thu, 31 Oct 2019 18:12:53 +0000 (20:12 +0200)]
modprobe: ignore builtin module on recursive removing
If there are built-in dependencies and any of them is built-in in
the kernel, modprobe -r fails with
modprobe: FATAL: Module module_name is builtin.
It makes sense to ignore such dependencies for the case when
removing is called for non-top level module.
Example: cifs module, it declares bunch of softdeps and the first
one fails on some kernel configs:
modprobe: FATAL: Module gcm is builtin.
Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Thomas Petazzoni [Thu, 24 Oct 2019 17:47:10 +0000 (19:47 +0200)]
Do not check for undefined symbols when building the Python modules
kmod's configure.ac uses the -Wl,--no-undefined linker flag to verify
at link time that all symbols of shared libraries are available, and
that there are no undefined symbols.
This make perfect sense for regular shared libraries. However, for
Python extensions, which will be dlopen()ed inside the Python
interpreter, it makes less sense.
Since Python 3.8, there is a change in python-config script and
Python's pkg-config file: it no longer links Python extensions with
the libpython library. See
https://docs.python.org/dev/whatsnew/3.8.html#debug-build-uses-the-same-abi-as-release-build
which states:
On the other hand, pkg-config python3.8 --libs no longer contains
-lpython3.8. C extensions must not be linked to libpython (except on
Android and Cygwin, whose cases are handled by the script); this
change is backward incompatible on purpose. (Contributed by Victor
Stinner in bpo-36721.)
So, when linking the kmod Python extensions, it currently fails with
numerous unresolved symbols, that were previously provided by
libpython:
/home/test/autobuild/run/instance-3/output-1/host/opt/ext-toolchain/bin/../lib/gcc/powerpc64-buildroot-linux-gnu/7.4.0/../../../../powerpc64-buildroot-linux-gnu/bin/ld: libkmod/python/kmod/.libs/list_la-list.o: in function `__Pyx_PyObject_GetAttrStr':
list.c:(.text.__Pyx_PyObject_GetAttrStr+0x48): undefined reference to `PyObject_GetAttr'
/home/test/autobuild/run/instance-3/output-1/host/opt/ext-toolchain/bin/../lib/gcc/powerpc64-buildroot-linux-gnu/7.4.0/../../../../powerpc64-buildroot-linux-gnu/bin/ld: libkmod/python/kmod/.libs/list_la-list.o: in function `__pyx_tp_dealloc_4kmod_4list_ModListItem':
list.c:(.text.__pyx_tp_dealloc_4kmod_4list_ModListItem+0x78): undefined reference to `PyObject_CallFinalizerFromDealloc'
/home/test/autobuild/run/instance-3/output-1/host/opt/ext-toolchain/bin/../lib/gcc/powerpc64-buildroot-linux-gnu/7.4.0/../../../../powerpc64-buildroot-linux-gnu/bin/ld: libkmod/python/kmod/.libs/list_la-list.o: in function `__pyx_tp_dealloc_4kmod_4list_ModList':
list.c:(.text.__pyx_tp_dealloc_4kmod_4list_ModList+0x30): undefined reference to `PyErr_Fetch'
[Complete log at http://autobuild.buildroot.net/results/79a/
79a5a0398723e8cfea0d0aa3dec5f7649aee4c63/build-end.log]
Linking with libpython is no longer recommended: those symbols should
remain unresolved in the Python extensions, as they wil be properly
resolved when the Python extension gets loaded into the Python
interpreter.
Since we want to keep -Wl,--no-undefined globally in kmod, we leave
the configure.ac file unchanged, and instead, specifically in the
LDFLAGS used to build the Python extensions, we override
-Wl,--no-undefined with -Wl,-z,undefs. Ideally, -Wl,--no-undefined is
the same as -Wl,-z,defs, and the effect of these options can be
canceled on the linker command line by a following -Wl,-z,undefs (see
the ld man page for details).
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Victor Stinner <victor.stinner@gmail.com>
Stefan Strogin [Sun, 19 May 2019 00:42:01 +0000 (03:42 +0300)]
libkmod-signature: use PKCS#7 instead of CMS
Linux uses either PKCS #7 or CMS for signing modules (see
scripts/sign-file.c). CMS is not supported by LibreSSL or older OpenSSL,
so PKCS #7 is used on systems with these libcrypto providers.
CMS and PKCS #7 formats are very similar. CMS is newer but is as much as
possible backward compatible with PKCS #7 [1]. PKCS #7 is supported in
the latest OpenSSL as well as CMS. The fields used for signing kernel
modules are supported both in PKCS #7 and CMS.
For now modinfo uses CMS with no alternative requiring OpenSSL 1.1.0 or
newer.
Use PKCS #7 for parsing module signature information, so that modinfo
could be used both with OpenSSL and LibreSSL.
[1] https://tools.ietf.org/html/rfc5652#section-1.1
Changes v1->v2:
- Don't use ifdefs for keeping redundant CMS code, just use PKCS #7 both
with OpenSSL and LibreSSL.
Signed-off-by: Stefan Strogin <steils@gentoo.org>
Ezequiel Garcia [Fri, 8 Mar 2019 20:39:07 +0000 (17:39 -0300)]
tools: Print a message if refcnt attribute is missing
Currently, check_module_inuse returns a wrong user message
if the kernel is built without module unloading support.
Fix it by returning a more specific error, in case 'refcnt'
attribute is missing.
Adrian Bunk [Wed, 20 Feb 2019 12:22:04 +0000 (14:22 +0200)]
build: Stop using dolt
This does regress "make -12" from 0.7s to 0.9s on my
Coffee Lake machine, but even on slower hardware this
will not amount to a noticable slowdown.
On the other hand using dolt can create problems for
people doing cross-compilation, e.g. Yocto has two
hacks just for dolt in kmod:
https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/recipes-kernel/kmod/kmod.inc?id=
a17abae00785c76cfffe5381a22fb2c86b982e82
(Lucas: remove leftover entry in Makefile and reformat commit message)
Dave Reisner [Wed, 13 Feb 2019 15:27:51 +0000 (10:27 -0500)]
Link against libcrypto, not all of openssl
In the previous build setup, libkmod.so would link to not just
libcrypto.so, but also libssl.so:
$ readelf -d /lib/libkmod.so | grep NEEDED
0x0000000000000001 (NEEDED) Shared library: [liblzma.so.5]
0x0000000000000001 (NEEDED) Shared library: [libz.so.1]
0x0000000000000001 (NEEDED) Shared library: [libssl.so.1.1]
0x0000000000000001 (NEEDED) Shared library: [libcrypto.so.1.1]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
We don't need any symbols from libssl, though. This patch ensures that
we pass 'libcrypto' to pkgconfig rather than 'openssl', getting only the
library that we need:
$ readelf -d ./libkmod/.libs/libkmod.so.2.3.4 | grep NEEDED
0x0000000000000001 (NEEDED) Shared library: [liblzma.so.5]
0x0000000000000001 (NEEDED) Shared library: [libz.so.1]
0x0000000000000001 (NEEDED) Shared library: [libcrypto.so.1.1]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
Lucas De Marchi [Thu, 7 Feb 2019 21:46:40 +0000 (13:46 -0800)]
kmod 26
Lucas De Marchi [Thu, 7 Feb 2019 21:44:39 +0000 (13:44 -0800)]
build: fix make distcheck
Make sure to add the dummy.pkcs7 file to the dist files.
While at it, also change the distcheck flags to include --with-openssl.
Lucas De Marchi [Tue, 5 Feb 2019 00:01:01 +0000 (16:01 -0800)]
testsuite: mkosi: update files
- Add openssl
- Disable python (quick hack to avoid more dependencies)
- Update Fedora to 29
Lucas De Marchi [Mon, 4 Feb 2019 23:02:20 +0000 (15:02 -0800)]
build: check openssl version
Lucas De Marchi [Mon, 4 Feb 2019 22:34:51 +0000 (14:34 -0800)]
build: add openssl to CI deps
Travis-ci is at most on Ubuntu 16.04, that doesn't have openssl >= 1.1,
so disable openssl there.
Semaphore 2.0 was also missing a call to update the package database.
Lucas De Marchi [Mon, 4 Feb 2019 22:27:29 +0000 (14:27 -0800)]
build: enable openssl by default
Like with other features, let's enable it for developers.
Lucas De Marchi [Mon, 4 Feb 2019 22:25:03 +0000 (14:25 -0800)]
testsuite: fix modinfo test without openssl
Yauheni Kaliuta [Fri, 1 Feb 2019 20:20:02 +0000 (22:20 +0200)]
libkmod-signature: implement pkcs7 parsing with openssl
The patch adds data fetching from the PKCS#7 certificate using
openssl library (which is used by scripts/sign-file.c in the linux
kernel to sign modules).
In general the certificate can contain many signatures, but since
kmod (modinfo) supports only one signature at the moment, only first
one is taken.
With the current sign-file.c certificate doesn't contain signer
key's fingerprint, so "serial number" is used for the key id.
Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Yauheni Kaliuta [Fri, 1 Feb 2019 20:36:41 +0000 (22:36 +0200)]
testsuite: add modinfo pkcs7 signature test
Use the same approach to generate the signed module, like in the
old signature test: just append the pregenerated binary signature
to the module (the signature check will fail).
In case of need of generating correct signature, from the linux
kernel makefiles (certs/Makefile) it could be like:
$ openssl req -new -nodes -utf8 -sha256 -days 36500 -batch -x509
-config ./x509.genkey -outform PEM -out signing_key.pem -keyout signing_key.pem
$ /lib/modules/$(uname -r)/build/scripts/extract-cert signing_key.pem signing_key.x509
$ /lib/modules/$(uname -r)/build/scripts/sign-file sha256 signing_key.pem signing_key.x509 module.ko
where x509.genkey is:
```
[ req ]
default_bits = 4096
distinguished_name = req_distinguished_name
prompt = no
string_mask = utf8only
x509_extensions = myexts
[ req_distinguished_name ]
CN = Build time autogenerated kernel key
[ myexts ]
basicConstraints=critical,CA:FALSE
keyUsage=digitalSignature
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid
```
Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Daniel Kahn Gillmor [Sat, 12 Jan 2019 17:22:19 +0000 (12:22 -0500)]
man: Fix typo
Yauheni Kaliuta [Fri, 4 Jan 2019 21:41:34 +0000 (23:41 +0200)]
testsuite: factor out fd related parameters to a structure
This is a more abstract implementation of "file descriptor
comparation". With the current implementation the code is full of
conditions based on the descriptor type. It makes sense to
initialize the parameters once based on the descriptor type.
stdout and stderr are handled in almost the same way, but for
monitor descriptor branch, based on the type check is necessary in
some cases.
Since epoll's context now contains pointers to the structures, so no
direct manipulations there.
Most of the patch is just replacing direct buffer manipulations with
the structures' ones.
Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Yauheni Kaliuta [Fri, 4 Jan 2019 21:41:33 +0000 (23:41 +0200)]
testsuite: track number of descriptors instead of their state
use the number of tracked descriptors to determine the end of the
loop.
This is a preparation for more abstract descriptor comparation
implementation where checking of the descriptor state may be more
expensive than just checking of the local variables.
Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Lucas De Marchi [Tue, 18 Dec 2018 22:11:58 +0000 (14:11 -0800)]
Add semaphoreci 2.0 configuration
Add another CI as alternative to travis-ci. Test on gcc 6, 7 and 8 on
Ubuntu 18.04. Not sure if this is the best way to define the yml file,
but it works.
The old badge doesn't work. It will be added back later.
Lucas De Marchi [Tue, 18 Dec 2018 23:37:35 +0000 (15:37 -0800)]
testsuite: move --show-exports test to use regex
This allows it to pass if the kernel is configured with
CONFIG_MODVERSIONS.
Lucas De Marchi [Tue, 18 Dec 2018 23:36:11 +0000 (15:36 -0800)]
testsuite: add support for testing output against regex
Allow to test outputs when they don't match exactly, but should follow
some regex patterns. This can be used when the info we are printing is
randomized or depends on kernel configuration.
Lucas De Marchi [Tue, 18 Dec 2018 21:42:09 +0000 (13:42 -0800)]
testsuite: split out function to compare outputs exactly
Move functionality to compare the exact output to a separate function
and allocate one buffer per output/match pair. This will allow us to
extend this to allow other types of comparisons. Since now we are using
heap-allocated buffer, keep the buffer allocation to the caller, so we
don't have to allocate and free it on every invocation. It also avoids
the different comparison functions to have to deal with it.
Michal Suchanek [Mon, 10 Dec 2018 21:29:34 +0000 (22:29 +0100)]
depmod: shut up gcc insufficinet buffer warning
In a couple of places depmod concatenates the module directory and filename
with snprintf. This can technically overflow creating an unterminated string if
module directory name is long. Use openat instead as is done elsewhere in
depmod. This avoids the snprintf, the extra buffer on stack, and the gcc
warning. It may even fix a corner case when the module direcotry name is just
under PATH_MAX.
[ Lucas: fix up coding style and closing fd on error path ]
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Michal Suchanek [Mon, 17 Dec 2018 22:46:28 +0000 (23:46 +0100)]
depmod: prevent module dependency files corruption due to parallel invocation.
Depmod does not use unique filename for temporary files. There is no
guarantee the user does not attempt to run mutiple depmod processes in
parallel. If that happens a temporary file might be created by
depmod(1st), truncated by depmod(2nd), and renamed to final name by
depmod(1st) resulting in corrupted file seen by user.
Due to missing mkstempat() this is more complex than it should be.
Adding PID and timestamp to the filename should be reasonably reliable.
Adding O_EXCL as mkstemp does fails creating the file rather than
corrupting existing file.
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Michal Suchanek [Mon, 10 Dec 2018 21:29:32 +0000 (22:29 +0100)]
depmod: prevent module dependency files missing during depmod invocation
depmod deletes the module dependency files before moving the temporary
files in their place. This results in user seeing no dependency files
while they are updated. Remove the unlink call. The rename call should
suffice to move the new file in place and unlink the old one. It should
also do both atomically so there is no window when no dependency file
exists.
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Lucas De Marchi [Mon, 17 Dec 2018 17:52:05 +0000 (09:52 -0800)]
Remove bootstrap* scripts
Let's just use autogen.sh, no need for wrapper scripts. Now
`autogen.sh c` uses the same recommended options for developing kmod and
also accepts extra arguments.
Lucas De Marchi [Fri, 30 Nov 2018 20:37:43 +0000 (12:37 -0800)]
README: Add link to mailing list archive
We now have a proper archive for the mailing list.
Yauheni Kaliuta [Fri, 16 Nov 2018 08:56:34 +0000 (10:56 +0200)]
signature: do not report wrong data for pkc#7 signature
when PKC#7 signing method is used the old structure doesn't contain
any useful data, but the data are encoded in the certificate.
The info getting/showing code is not aware of that at the moment and
since 0 is a valid constant, shows, for example, wrong "md4" for the
hash algo.
The patch splits the 2 mothods of gethering the info and reports
"unknown" for the algo.
Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Lucas De Marchi [Tue, 13 Nov 2018 18:45:00 +0000 (10:45 -0800)]
testsuite: add simple test for --show-exports
Yauheni Kaliuta [Tue, 13 Nov 2018 09:00:29 +0000 (11:00 +0200)]
modprobe: add --show-exports
modprobe has --show-modversions switch, which dumps symbols with
their modversion crcs from the __versions sections.
At the moment the section contains information for the dependency
symbols only, while exported symbols add to symtab entries with
__crc_ prefix (the format may differ, see
1e48901166ef libkmod-elf:
resolve CRC if module is built with MODULE_REL_CRCS).
The patch makes it to show exported symbols as well.
The function is basically cut'n'paste of show_modversions(),
but 'version' family replaced with 'symbol' one.
Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Lucas De Marchi [Wed, 10 Oct 2018 20:47:50 +0000 (13:47 -0700)]
mkosi: allow Clear to use test modules
Now Clear has a bundle for the kernel headers, let's use it.
Lucas De Marchi [Fri, 20 Jul 2018 20:23:57 +0000 (13:23 -0700)]
man: depmod: remove deprecated -m option
Thanks to Howard Johnson <hwj@bridgeportcontractor.com> for noticing.
Jan Engelhardt [Sat, 16 Jun 2018 06:45:20 +0000 (08:45 +0200)]
kmod: build: cure compiler warnings showing up externally
When building a C source file with gcc-7 -Wshift-overflow=2, this warning
springs up:
libkmod.h: warning: result of "1 << 31" requires 33 bits to
represent, but "int" only has 32 bits [-Wshift-overflow=]
Change the two _KMOD_* identifiers to fit into 32 bits.
Jakov Simunic [Wed, 16 May 2018 17:24:37 +0000 (10:24 -0700)]
build: fix wrong quotes on bootstrap
Chris Stackpole [Fri, 20 Apr 2018 19:46:58 +0000 (14:46 -0500)]
Phrasing correction in modprobe man page
Luca Bruno [Wed, 7 Mar 2018 10:51:21 +0000 (10:51 +0000)]
libkmod-module: check for NULL before accessing pointers
This introduces a few missing NULL-checks in public functions, and
align their docstrings with real behavior by getting rid of copy-paste
mistakes.
Signed-off-by: Luca Bruno <luca.bruno@coreos.com>
Lucas De Marchi [Fri, 9 Feb 2018 17:19:53 +0000 (09:19 -0800)]
testsuite: raise arch image to 3GB
Caio Marcelo de Oliveira Filho [Thu, 8 Feb 2018 23:08:22 +0000 (15:08 -0800)]
testsuite: add Clear's mkosi configuration
Adapted the mkosi.build script to account for not building
test-modules in Clear. It doesn't have the headers available yet.
Lucas De Marchi [Tue, 9 Jan 2018 01:30:39 +0000 (17:30 -0800)]
kmod 25
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).
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.
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.
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.
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.
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.
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.
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>
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>
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>
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>
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>
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>
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>
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>
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>
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)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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>
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>
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>
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>
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>
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>
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>
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>
Lucas De Marchi [Fri, 24 Feb 2017 07:32:51 +0000 (23:32 -0800)]
kmod 24
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.
Lucas De Marchi [Fri, 24 Feb 2017 05:47:37 +0000 (21:47 -0800)]
depmod: fix leak on error path
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
Lucas De Marchi [Fri, 24 Feb 2017 02:26:54 +0000 (18:26 -0800)]
build: add missing header
Fix failing distcheck
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>
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>
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.
Lucas De Marchi [Thu, 16 Feb 2017 16:57:01 +0000 (08:57 -0800)]
libkmod-config: replace 0/1 with bool
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>
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.
Lucas De Marchi [Mon, 23 Jan 2017 19:58:29 +0000 (11:58 -0800)]
testsuite: fix typo in description