]> git.ipfire.org Git - thirdparty/kmod.git/log
thirdparty/kmod.git
4 years agoLookup aliases in the modules.builtin.modinfo
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>
4 years agolibkmod: Add function to get list of built-in modules
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>
4 years agolibkmod: Add parser for modules.builtin.modinfo
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>
4 years agoMakefile.am: filter -Wl,--no-undefined
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>
4 years agomodprobe: use flags rather than bool args
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.

4 years agotravis: remove old compiler failing to build kernel module
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.

4 years agotestsuite: update gitignore
Lucas De Marchi [Thu, 7 Nov 2019 07:30:16 +0000 (23:30 -0800)] 
testsuite: update gitignore

4 years agomodprobe: ignore builtin module on recursive removing
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>
4 years agoDo not check for undefined symbols when building the Python modules
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>
4 years agolibkmod-signature: use PKCS#7 instead of CMS
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>
5 years agotools: Print a message if refcnt attribute is missing
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.

5 years agobuild: Stop using dolt
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)

5 years agoLink against libcrypto, not all of openssl
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]

5 years agokmod 26 v26
Lucas De Marchi [Thu, 7 Feb 2019 21:46:40 +0000 (13:46 -0800)] 
kmod 26

5 years agobuild: fix make distcheck
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.

5 years agotestsuite: mkosi: update files
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

5 years agobuild: check openssl version
Lucas De Marchi [Mon, 4 Feb 2019 23:02:20 +0000 (15:02 -0800)] 
build: check openssl version

5 years agobuild: add openssl to CI deps
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.

5 years agobuild: enable openssl by default
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.

5 years agotestsuite: fix modinfo test without openssl
Lucas De Marchi [Mon, 4 Feb 2019 22:25:03 +0000 (14:25 -0800)] 
testsuite: fix modinfo test without openssl

5 years agolibkmod-signature: implement pkcs7 parsing with 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>
5 years agotestsuite: add modinfo pkcs7 signature test
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>
5 years agoman: Fix typo
Daniel Kahn Gillmor [Sat, 12 Jan 2019 17:22:19 +0000 (12:22 -0500)] 
man: Fix typo

5 years agotestsuite: factor out fd related parameters to a structure
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>
5 years agotestsuite: track number of descriptors instead of their state
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>
5 years agoAdd semaphoreci 2.0 configuration
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.

5 years agotestsuite: move --show-exports test to use regex
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.

5 years agotestsuite: add support for testing output against regex
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.

5 years agotestsuite: split out function to compare outputs exactly
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.

5 years agodepmod: shut up gcc insufficinet buffer warning
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>
5 years agodepmod: prevent module dependency files corruption due to parallel invocation.
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>
5 years agodepmod: prevent module dependency files missing during depmod invocation
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>
5 years agoRemove bootstrap* scripts
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.

5 years agoREADME: Add link to mailing list archive
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.

5 years agosignature: do not report wrong data for pkc#7 signature
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>
5 years agotestsuite: add simple test for --show-exports
Lucas De Marchi [Tue, 13 Nov 2018 18:45:00 +0000 (10:45 -0800)] 
testsuite: add simple test for --show-exports

5 years agomodprobe: add --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>
5 years agomkosi: allow Clear to use test modules
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.

5 years agoman: depmod: remove deprecated -m option
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.

5 years agokmod: build: cure compiler warnings showing up externally
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.

5 years agobuild: fix wrong quotes on bootstrap
Jakov Simunic [Wed, 16 May 2018 17:24:37 +0000 (10:24 -0700)] 
build: fix wrong quotes on bootstrap

5 years agoPhrasing correction in modprobe man page
Chris Stackpole [Fri, 20 Apr 2018 19:46:58 +0000 (14:46 -0500)] 
Phrasing correction in modprobe man page

6 years agolibkmod-module: check for NULL before accessing pointers
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>
6 years agotestsuite: raise arch image to 3GB
Lucas De Marchi [Fri, 9 Feb 2018 17:19:53 +0000 (09:19 -0800)] 
testsuite: raise arch image to 3GB

6 years agotestsuite: add Clear's mkosi configuration
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.

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