Commit Graph

1396 Commits

Author SHA1 Message Date
Lucas De Marchi
594f102cf5 Drop python bindings
Python bindings are not well maintained. Currently it's just broken when
trying to build with cython 3.0.8:

	make --no-print-directory all-recursive
	Making all in .
	  CYTHON  libkmod/python/kmod/kmod.c

	Error compiling Cython file:
	------------------------------------------------------------
	...
	# details.
	#
	# You should have received a copy of the GNU Lesser General Public License
	# along with python-kmod.  If not, see <http://www.gnu.org/licenses/>.

	cimport _libkmod_h
		^

Nothing really touched those bindings for 10 years already.
I postponed the removal since they were at least building, but that just
changed. So let's drop it and allow any interested people to give it
a better life outside of libkmod.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-02-02 12:54:04 -06:00
Michal Suchanek
48b0c75f79 configure: Check that provided paths are absolute
configure checks that its built-in directory options get an absolute
path. Copy the check for custom options.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Link: https://lore.kernel.org/r/8aff0c9c491d8afeec7f6b2cd96cbd0439e26fbb.1699618135.git.msuchanek@suse.de
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-12-06 09:53:41 -06:00
Michal Suchanek
9d1fb317c8 libkmod, depmod, modprobe: Make directory for kernel modules configurable
Now that modprobe.d is searched under ${prefix}/lib, allow a complete
transition to files only under ${prefix} by adding a ${module_directory}
configuration. This specifies the directory where to search for kernel
modules and should match the location where the kernel/distro installs
them.

With this distributions that do not want to ship files in /lib can also
move kernel modules to /usr while others can keep them in /lib.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Link: https://lore.kernel.org/r/a3765f4e8ae3ce29c0847a0132d4a8d51ad040a9.1699618135.git.msuchanek@suse.de
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-12-06 09:53:05 -06:00
Dimitri John Ledkov
510c8b7f74 libkmod: remove pkcs7 obj_to_hash_algo()
Switch to using OBJ_obj2txt() to calculate and print the pkcs7
signature hash name. This eliminates the need to duplicate libcrypto
NID to name mapping, detect SM3 openssl compile-time support, and
enables using any hashes that openssl and kernel know about. For
example SHA3 are being added for v6.7 and with this patch are
automatically supported.

Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
Link: https://lore.kernel.org/r/20231029010319.157390-1-dimitri.ledkov@canonical.com
2023-11-07 14:05:44 -06:00
Sam James
3af2f475b0 tools: depmod: fix -Walloc-size
GCC 14 introduces a new -Walloc-size included in -Wextra which gives:
```
tools/depmod.c:192:14: warning: allocation of insufficient size ‘1’ for type ‘struct index_node’ with size ‘1048’ [-Walloc-size]
tools/depmod.c:255:11: warning: allocation of insufficient size ‘1’ for type ‘struct index_value’ with size ‘16’ [-Walloc-size]
tools/depmod.c:286:35: warning: allocation of insufficient size ‘1’ for type ‘struct index_node’ with size ‘1048’ [-Walloc-size]
tools/depmod.c:315:44: warning: allocation of insufficient size ‘1’ for type ‘struct index_node’ with size ‘1048’ [-Walloc-size]
```

The calloc prototype is:
```
void *calloc(size_t nmemb, size_t size);
```

So, just swap the number of members and size arguments to match the prototype, as
we're initialising 1 struct of size `sizeof(struct ...)`. GCC then sees we're not
doing anything wrong.

Signed-off-by: Sam James <sam@gentoo.org>
2023-11-05 18:22:05 -06:00
Michal Suchanek
ecef7c1316 kmod: Add pkgconfig file with kmod compile time configuration
Show distconfdir (where system configuration files are searched/to be
installed), sysconfdir (where user configuration files are searched),
module compressions, and module signatures supported.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Link: https://lore.kernel.org/r/468b3f572d3b84f25bb53ec8fcb15ed4871914d4.1689681454.git.msuchanek@suse.de
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-10-17 12:27:59 -05:00
Michal Suchanek
8463809f8a libkmod, depmod: Load modprobe.d, depmod.d from ${prefix}/lib.
There is an ongoing effort to limit use of files outside of /usr (or
${prefix} on general). Currently all modprobe.d paths are hardcoded to
outside of $prefix. Teach kmod to load modprobe.d from ${prefix}/lib.

On some distributions /usr/lib and /lib are the same directory because
of a compatibility symlink, and it is possible to craft configuration
files with sideeffects that would behave differently when loaded twice.
However, the override semantic ensures that one 'overrides' the other,
and only one configuration file of the same name is loaded from any of
the search directories.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Link: https://lore.kernel.org/r/a290343ce32e2a3c25b134e4f27c13b26e06c9e0.1689681454.git.msuchanek@suse.de
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-10-17 12:27:59 -05:00
Michal Suchanek
4e7effbdc0 man/depmod.d: Fix incorrect /usr/lib search path
depmod searches /lib/depmod.d but the man page says /usr/lib/depmod.d is
searched. Align the documentation with the code.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Link: https://lore.kernel.org/r/9c5a6356b1a111eb6e17ddb110494b7f1d1b44c0.1689681454.git.msuchanek@suse.de
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-10-17 12:27:59 -05:00
Michal Suchanek
1bb23d7f19 configure: Detect openssl sm3 support
Older openssl versions do not support sm3. The code has an option to
disable the sm3 hash but the lack of openssl support is not detected
automatically.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Link: https://lore.kernel.org/r/b97e20faa07e9e31c6eaf96683011aa24e80760c.1689681454.git.msuchanek@suse.de
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-10-17 12:27:59 -05:00
Lucas De Marchi
aff617ea87 kmod 31 2023-09-29 09:18:37 -05:00
Emil Velikov
0140db94c0 libkmod: add fallback MODULE_INIT_COMPRESSED_FILE define
The symbol was somewhat recently introduced by the kernel and not all
distributions may be have available.

The number is part of the ABI, so we can add a local fallback define.

Closes: https://github.com/kmod-project/kmod/issues/29
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-09-27 22:37:45 -05:00
Lucas De Marchi
09c9f8c5df libkmod: Use kernel decompression when available
With the recent changes to bypass loading the file it's possible to
reduce the work in userspace and delegating it to the kernel. Without
any compression to illustrate:

Before:
	read(3, "\177ELF\2\1", 6)               = 6
	lseek(3, 0, SEEK_SET)                   = 0
	newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=238592, ...}, AT_EMPTY_PATH) = 0
	mmap(NULL, 238592, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fd85cbd1000
	finit_module(3, "", 0)                  = 0
	munmap(0x7fd85cbd1000, 238592)          = 0
	close(3)                                = 0

After:
	read(3, "\177ELF\2\1", 6)               = 6
	lseek(3, 0, SEEK_SET)                   = 0
	finit_module(3, "", 0)                  = 0
	close(3)                                = 0

When using kernel compression now it's also possible to direct libkmod
to take the finit_module() path, avoiding the decompression in userspace
and just delegating it to the kernel.

Before:
	read(3, "(\265/\375\244\0", 6)          = 6
	lseek(3, 0, SEEK_SET)                   = 0
	read(3, "(\265/\375\244", 5)            = 5
	mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f3fa431e000
	read(3, "\0\244\3\0\\y\6", 7)           = 7
	mmap(NULL, 372736, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f3fa414f000
	brk(0x55944c6a1000)                     = 0x55944c6a1000
	read(3, "\356|\6G\27U\20 \312\260s\211\335\333\263\326\330\336\273O\211\356\306K\360Z\341\374U6\342\221"..., 53038) = 53038
	mremap(0x7f3fa431e000, 135168, 266240, MREMAP_MAYMOVE) = 0x7f3fa410e000
	read(3, ",;\3\nqf\311\362\325\211\7\341\375A\355\221\371L\\\5\7\375 \32\246<(\258=K\304"..., 20851) = 20851
	mremap(0x7f3fa410e000, 266240, 397312, MREMAP_MAYMOVE) = 0x7f3fa40ad000
	read(3, ")\36\250\213", 4)              = 4
	read(3, "", 4)                          = 0
	munmap(0x7f3fa414f000, 372736)          = 0
	init_module(0x7f3fa40ad010, 238592, "") = 0
	munmap(0x7f3fa40ad000, 397312)          = 0
	close(3)                                = 0

After:
	read(3, "(\265/\375\244P", 6)           = 6
	lseek(3, 0, SEEK_SET)                   = 0
	finit_module(3, "", 0x4 /* MODULE_INIT_??? */) = 0
	close(3)                                = 0

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-06-20 14:39:25 -07:00
Lucas De Marchi
30077bf171 libkmod: Keep track of in-kernel compression support
When creating the context, read /sys/kernel/compression to check what's
the compression type supported by the kernel. This will later be used
when loading modules to check if the decompression step has to happen in
userspace or if it can be delegated to the kernel.

Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-06-09 10:45:55 -07:00
Lucas De Marchi
e539827635 libkmod: Keep track of compression type
Do not only set the type as direct, but also keep track of the
compression being used. This will allow using the in-kernel compression
in future.

Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-06-09 10:45:55 -07:00
Lucas De Marchi
e1f0e169de libkmod: Extract finit_module vs init_module paths
Extract 2 functions to handle finit_module vs init_modules differences,
with a fallback from the former to the latter.

Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-06-09 10:45:55 -07:00
Lucas De Marchi
7a86f12920 libkmod: Do not inititialize file->memory on open
Add a separate function to load the file contents when it's needed.
When it's not needed on the path of loading modules via finit_module(),
there is no need to mmap the file. This will help support loading
modules with the in-kernel compression support.

This is done differently than the lazy initialization for
kmod_file_get_elf() because on the contents case there is also the
file->size to be updated. It would be a weird API to return the pointer
and have the size changed as a side-effect.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-06-09 10:45:51 -07:00
Dmitry Antipov
9c262fdb1c shared: avoid passing {NULL, 0} array to bsearch()
Fix the following warning reported by UBSan (as of gcc-13.1.1):

shared/hash.c:244:35: runtime error: null pointer passed as
argument 2, which is declared to never be null

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
[ reshuffle the code to use return-early style ]
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-05-30 22:36:43 -07:00
Dmitry Antipov
badacf76e4 libkmod: fix possible out-of-bounds memory access
An attempt to pass too long module name to, say, rmmod, may
cause an out-of-bounds memory access (as repoted by UBSan):

$ rmmod $(for i in $(seq 0 4200); do echo -ne x; done)
libkmod/libkmod-module.c:1828:8: runtime error: index 4107 out of bounds for type 'char [4096]'

This is because 'snprintf(path, sizeof(path), ...)' may return the
value which exceeds 'sizeof(path)' (which happens when an output
gets truncated). To play it safe, such a suspicious output is
better to be rejected explicitly.

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Link: https://lore.kernel.org/r/20230519074638.402045-1-dmantipov@yandex.ru
2023-05-30 12:56:54 -07:00
Dmitry Antipov
5c004af29d libkmod, depmod: prefer -ENODATA over -ENOENT if no section found
When the module is definitely present but CONFIG_MODVERSIONS is
disabled, the following error message may be somewhat confusing:

modprobe --dump-modversions /path/to/module.ko.xz
modprobe: FATAL: could not get modversions of /path/to/module.ko.xz: No such file or directory

Choosing among the convenient errno values, I would suggest to use
ENODATA when the module lacks a particular ELF section (and vermagic
as well). So now it is expected to be:

modprobe: FATAL: could not get modversions of /path/to/module.ko.xz: No data available

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Link: https://lore.kernel.org/r/20230519093630.474185-1-dmantipov@yandex.ru
2023-05-30 12:54:12 -07:00
Nicolas Schier
116e7c7fc0 modprobe: rmmod_do_module: Free kmod list of holders
Add a missing kmod_module_unref_list() to fix a memory leak.

Fixes: 42b32d30c3 ("modprobe: Fix holders removal")
Signed-off-by: Nicolas Schier <n.schier@avm.de>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-04-18 15:51:12 -07:00
Fabrice Fontaine
3d1bd339ab configure.ac: fix link with -llzma
Add liblzma_LIBS to LIBS to avoid the following build failure when
building with a static-only liblzma.a:

/home/autobuild/autobuild/instance-5/output-1/host/lib/gcc/xtensa-buildroot-linux-uclibc/11.3.0/../../../../xtensa-buildroot-linux-uclibc/bin/ld: libkmod/.libs/libkmod-internal.a(libkmod-file.o):(.text.xz_uncompress+0x10): undefined reference to `lzma_code'

For consistency, also update libzstd, zlib and libcrypto

Fixes:
 - http://autobuild.buildroot.org/results/83a4a7ecc77f39639d3e5bc8554bd01a62a3ede0

References: https://github.com/kmod-project/kmod/pull/25
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-03-06 14:21:51 -08:00
Emil Velikov
e4c1a5b299 configure: manage libkmod.pc.in and version.py.in via AC_CONFIG_FILES
Replace the manual sed command, build rules and dist/clean for using
AC_CONFIG_FILES. It does the exact same thing, with an added bonus...

Currently we're missing version.py.in in the EXTRA_DIST. Thus a simple
"touch Makefile" should retrigger the regeneration of version.py. Which
would presumably fail, since the input file isn't in the distribution
tarball.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-02-21 16:35:42 -08:00
Emil Velikov
06e6f167c2 shared: annotate local API as static
None of the API is used outside of the compilation unit.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-02-21 16:35:42 -08:00
Emil Velikov
df9d07a149 libkmod: annotate kmod_builtin_iter API as static
It's no longer used outside the compilation unit, as of last commit.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-02-21 16:35:37 -08:00
Emil Velikov
0237665bef libkmod: remove unused kmod_module_get_builtin
The last and only user was removed with commit 0246e06 ("depmod: Stop
opening modules.modinfo once per module")

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-02-21 16:35:14 -08:00
Lucas De Marchi
3d38e322f9 testsuite: Handle different sysconfdir
Instead of skipping tests if sysconfdir isn't /etc, just handle it
during the rootfs setup logic.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2023-02-10 14:29:28 -08:00
Lucas De Marchi
184a070733 testsuite: Move setup-rootfs logic from Makefile to script
It's easier to implement the logic outside of the Makefile, so rename
the populate-modules.sh script to setup-rootfs.sh and move the
additional logic from the makefile to the script.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2023-02-10 14:27:27 -08:00
Emil Velikov
b9605c63b8 libkmod: error out on unknown hash algorithm
Currently if we see unknown algorithm, we'll do an OOB read in
pkey_hash_algo. This can happen for example if OPENSSL_NO_SM3 is set and
the kernel module uses a SM3 hash.

Cc: Mikhail Novosyolov <m.novosyolov@rosalinux.ru>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-02-09 12:08:14 -08:00
Emil Velikov
96152dd687 testsuite/depmod: use defines for the rootfs/lib_modules
The uname used across the tests is same, so drop "_ORDER" from the macro
name and use it throughout. Similarly - add respective LIB_MODULES
defines and use them in the tests.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-02-09 11:11:40 -08:00
Emil Velikov
6661e5970a testsuite: add function declarations for __xstat family
As the inline comment says - the declarations have been dropped with
glibc 2.32.9000, as a result the build throws a set of lovely warnings.

Inspired by umockdev, which bears the same license as this project.
f1b4164004

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-02-09 07:16:06 -08:00
Emil Velikov
efc2e4b467 treewide: add some static const notations
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-02-09 07:15:56 -08:00
Emil Velikov
1712a1548e depmod: Introduce outdir option
This option is equivalent to basedir, with the small difference being
that's where the meta-data files are generated. In other words, this
allows us to have read-only input modules and modules.dep, while still
being able to generate the meta-data files.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
[ Move files to a different dir so input files (produced by kernel build
  system is separate from the files generated by depmod (output) ]
Signed-off-by: Lucas De Marchi <lucas.demarchi@gmail.com>
2023-02-09 07:09:06 -08:00
Yauheni Kaliuta
06fadcc6b1 man/rmmod: explain why modprobe -r is more useful
Improve user experience by explaining the option so the user may
not search explanations in other manpages (modprobe).

Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-02-08 09:10:05 -08:00
Gustavo Sousa
883d931d1b modprobe: Allow passing path to module
This is useful to kernel module developers for testing a just compiled
module: instead of using insmod, they can load the module from the path
while getting all the benefits of modprobe (e.g. module dependency
resolution).

v2:
  - Add test for relative path as well. (Lucas)
  - Add note warning about modules with dependencies not matching the
    installed depmod database. (Lucas)

Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-01-13 16:48:02 -08:00
Gustavo Sousa
f3db15e900 modprobe: Move insertion block into separate function
That same logic will be used for enabling modprobe for paths in the next
patch. As such, prepare for that by extracting that block into its own
function.

Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-01-13 16:48:02 -08:00
Gustavo Sousa
e54f74c4f7 testsuite: Wrap chdir()
One of the tests in an upcoming patch will need to change into a
specific directory to test loading a module from a relative path.

Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2023-01-13 16:48:02 -08:00
Florian Weimer
035e6667d1 kmod: configure.ac: In _Noreturn check, include <stdlib.h> for exit
Otherwise, an implicit functiona declaration is used, causing
a C99 compatibility issue.

Signed-off-by: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2022-12-26 09:33:47 -08:00
Adam Gołębiowski
6c5f2f1368 autogen.sh: remove --with-rootprefix, it is gone since kmod-11
Signed-off-by: Adam Gołębiowski <adamg@pld-linux.org>
2022-11-30 22:01:01 -08:00
Mikhail Novosyolov
d5950b0b5e libkmod: do not crash on unknown signature algorithm
Example kernel module:
https://file-store.rosalinux.ru/download/7281f97e0c04c0f818ad3f936706f4a407e8dc7e
(/lib/modules/5.15.67-generic-1rosa2021.1-x86_64/kernel/drivers/usb/host/xhci-pci.ko.zst)
It is signed with Streebog 512.

libkmod v30 crashed in libkmod-module.c:2413 in this code:

n = kmod_module_info_append(list,
	"sig_hashalgo", strlen("sig_hashalgo"),
	sig_info.hash_algo, strlen(sig_info.hash_algo));

because strlen() got null.
2022-10-03 06:59:41 -07:00
Julien Cristau
b4d281f962 testsuite: fix override of stat on 32-bit architectures
When _FILE_OFFSET_BITS is 64, glibc headers turn `stat` calls into
`stat64`, and our `stat` override into a `stat64` function.  However,
because we use dlsym to get the address of libc's `stat`, we end up
calling into the "real" `stat` function, which deals with 32-bit off_t,
and we treat its result as if it were returned from stat64.  On most
architectures this seems to have been harmless, but on 32-bit mips,
st_mode's offset in struct stat and struct stat64 are different, so we
read garbage.

To fix this, explicitly unset _FILE_OFFSET_BITS in path.c, to turn off
the redirect magic in glibc headers, and override both the 32-bit and
64-bit functions so each call ends up wrapping the right libc function.

Fixes #16 (https://github.com/kmod-project/kmod/issues/16)
2022-09-05 13:35:09 -07:00
Quentin Armitage
c1fb98a30d modprobe: Write error messages to syslog if stderr is unavailable
The man page modprobe(8) states for the --syslog option:
"This is also automatically enabled when stderr is unavailable."
but it wasn't happening.

This commit now makes modprobe write to syslog if stderr is closed.
2022-06-30 09:59:38 -07:00
Dimitri John Ledkov
09ad860552 build: enable building & running tests from a subdir
During dpkg build, in a subdir, it is currently not possible to run
tests. Building testsuite/modules due to non-existance of the
testsuite directory under the build dir. Thus create it, when it is
not there.

Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
2022-06-30 09:55:55 -07:00
Jan Engelhardt
16c086f48c testsuite: repair read of uninitialized memory
Function ``test_backoff_time`` does not initialize ``delta``, and
``get_backoff_delta_msec`` then performs a read from uninitialized
memory with the ``!*delta`` expression.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2022-06-30 09:54:23 -07:00
Lucas De Marchi
5d46434a63 kmod 30 2022-06-30 08:19:17 -07:00
HuaxinLu
f609cb5185 libkmod: Support SM3 hash algorithm
SM3 has been supported in kernel and cryptographic libraries like openssl.
This patch adds support for the SM3 algorithm of kmod.

Signed-off-by: HuaxinLu <luhuaxin1@huawei.com>
2022-06-30 07:44:32 -07:00
Lucas De Marchi
edc7f3a2d3 README: Update optional dependencies
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2022-06-29 00:10:04 -07:00
Lucas De Marchi
202040cbc7 Keep only one readme
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2022-06-28 22:24:33 -07:00
Lucas De Marchi
2b98ed8886 modprobe: Add --wait
Retry module removal if it fails due to EAGAIN. This allows user to pass
--wait <timeout>, during which `modprobe -r` will keep trying to remove
the module.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2022-06-26 23:23:46 -07:00
Lucas De Marchi
b253f4c835 testsuite: Add tests for sleep calculation
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2022-06-26 23:23:46 -07:00
Lucas De Marchi
8ab15eceaf util: Add exponential backoff sleep
Add simple functions to put the current thread to sleep using
exponential backoff to split the interval in smaller pieces.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2022-06-26 23:23:46 -07:00