]> git.ipfire.org Git - thirdparty/kmod.git/log
thirdparty/kmod.git
6 weeks agolibkmod: Fix open file which some char device master
Wentao Guan [Thu, 19 Feb 2026 15:45:10 +0000 (23:45 +0800)] 
libkmod: Fix open file which some char device

use lseek SEEK_CUR to get whether it is a regular file,
lseek return -ESPIPE when fd is associated with a pipe, socket, or FIFO.

commit 883d931d1bd04b089b85b554d1df6f41dcf5fbf5 upstream
("modprobe: Allow passing path to module") allow to modprobe a file,
but not handle opening a FIFO device such as modprobe /dev/tty1.

commit 8d03b6c7d990af301950d3ecdc4b5c69fa525928 uptream
("libkmod: Use pread where appropriate") fix some cases,
such as open /dev/tty1, but not for /dev/vmnet0 or /dev/userio etc.

Can be reproduced in run lshw in root and install some vm such ad vmware,
more about the case are in the Link.

Reference: https://github.com/lyonel/lshw/pull/110
Closes: https://bugs.launchpad.net/ubuntu/+source/lshw/+bug/2069649
Closes: https://bbs.deepin.org.cn/post/291466
Reported-by: Qi Xu <xuqi@uniontech.com>
Reported-by: lionheartyu <dongshengyuan@uniontech.com>
Fixes: 883d931d1bd04 ("modprobe: Allow passing path to module")
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/407
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 weeks agotestsuite: Prefer _cleanup_free_ to free temp storage
Lucas De Marchi [Thu, 12 Feb 2026 16:36:35 +0000 (10:36 -0600)] 
testsuite: Prefer _cleanup_free_ to free temp storage

`preload` is freed in all exit paths, just use _cleanup_free_ to avoid
bugs like the one fixed in commit e1d21ab27277 ("testsuite: Fix memory
leak in test_export_environ error paths").

As noted by Emil, there's one place where the free() can't be removed:
when we are replacing what preload points to. Keep that one, zap the
rest.

Link: https://github.com/kmod-project/kmod/pull/423
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 weeks agotestsuite: Fix memory leak in test_export_environ error paths
jared mauch [Thu, 12 Feb 2026 13:54:14 +0000 (13:54 +0000)] 
testsuite: Fix memory leak in test_export_environ error paths

[emil: split from larger patch, commit message]
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/423
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 weeks agotools/depmod: Fix memory leak in depmod_module_add error path
jared mauch [Thu, 22 Jan 2026 04:25:31 +0000 (23:25 -0500)] 
tools/depmod: Fix memory leak in depmod_module_add error path

[emil: split from larger patch, commit message]
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/423
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 weeks agoshared/util.h: Protect custom overflow checks
Tobias Stoeckmann [Fri, 23 Jan 2026 11:20:14 +0000 (12:20 +0100)] 
shared/util.h: Protect custom overflow checks

Make sure that division by zero is never possible.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/415
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 weeks agoshared/util.h: Use generic for size_t arithmetic
Tobias Stoeckmann [Thu, 22 Jan 2026 19:20:41 +0000 (20:20 +0100)] 
shared/util.h: Use generic for size_t arithmetic

This improves support for rare systems like s390 in 31 bit mode, where
the size of size_t is equals uint32_t, yet types still differ.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/415
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
8 weeks agoci: bump the all-actions group across 1 directory with 2 updates
dependabot[bot] [Sun, 1 Feb 2026 01:24:24 +0000 (01:24 +0000)] 
ci: bump the all-actions group across 1 directory with 2 updates

Bumps the all-actions group with 2 updates in the / directory: [actions/checkout](https://github.com/actions/checkout) and [github/codeql-action](https://github.com/github/codeql-action).

Updates `actions/checkout` from 6.0.1 to 6.0.2
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/8e8c483db84b4bee98b60c0593521ed34d9990e8...de0fac2e4500dabe0009e67214ff5f5447ce83dd)

Updates `github/codeql-action` from 4.31.9 to 4.32.0
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/5d4e8d1aca955e8d8589aabd499c5cae939e33c7...b20883b0cd1f46c72ae0ba6d1090936928f9fa30)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 6.0.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-actions
- dependency-name: github/codeql-action
  dependency-version: 4.32.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Link: https://github.com/kmod-project/kmod/pull/419
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
8 weeks agoConsistently use endian.h swapping API
Emil Velikov [Sun, 8 Feb 2026 14:43:31 +0000 (14:43 +0000)] 
Consistently use endian.h swapping API

A handful of places are still using the old "networking" API. Swap that
with the usual (no longer GNU/glibc specific) ntobe*/be*toh.

Be that to stay consistent, to improve clarity or to celebrate that the
later is part of POSIX (2024) - take your pick.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/421
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
8 weeks agoutil: Use const variable type in mkdir_parents
Rudi Heitbaum [Sun, 8 Feb 2026 14:49:49 +0000 (01:49 +1100)] 
util: Use const variable type in mkdir_parents

For ISO C23, the function strchr that return pointers into their input
arrays now have definitions as macros that return a pointer to a
const-qualified type when the in put argument is a pointer to a
const-qualified type.

Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/pull/422
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
8 weeks agoUse $(uname -r) throughout
Emil Velikov [Wed, 28 Jan 2026 15:21:10 +0000 (15:21 +0000)] 
Use $(uname -r) throughout

The backtick notation is considered deprecated, I believe. We already
have a handful of $(...) instances, so if nothing else it's better to
stay consistent.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/pull/416
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
8 weeks agoman/modprobe.8: use MODULE_DIRECTORY as applicable
Emil Velikov [Wed, 28 Jan 2026 15:08:37 +0000 (15:08 +0000)] 
man/modprobe.8: use MODULE_DIRECTORY as applicable

The original XML based documentation was referencing MODULE_DIRECTORY
which got erroneously swapped to DISTCONFDIR during the scdoc
conversion.

Closes: https://github.com/kmod-project/kmod/issues/410
Fixes: f3a423b6 ("man: add scdoc based man pages")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/pull/416
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agolibkmod/README.md: convert to markdown
Emil Velikov [Wed, 28 Jan 2026 21:05:51 +0000 (21:05 +0000)] 
libkmod/README.md: convert to markdown

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/417
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agotestsuite/README.md: convert to markdown
Emil Velikov [Wed, 28 Jan 2026 21:04:03 +0000 (21:04 +0000)] 
testsuite/README.md: convert to markdown

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/417
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agoCODING-STYLE.md: mention clang-format
Emil Velikov [Wed, 28 Jan 2026 20:09:17 +0000 (20:09 +0000)] 
CODING-STYLE.md: mention clang-format

Copy/paste the section from CONTRIBUTING.md, completing the circle.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/417
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agoCODING-STYLE.md: update line wrapping section
Emil Velikov [Wed, 28 Jan 2026 20:04:42 +0000 (20:04 +0000)] 
CODING-STYLE.md: update line wrapping section

We follow the tab + spaces, alongside a 90 col (soft) limit.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/417
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agoCODING-STYLE.md: trim down the inspiration section
Emil Velikov [Wed, 28 Jan 2026 19:56:10 +0000 (19:56 +0000)] 
CODING-STYLE.md: trim down the inspiration section

Omit nearly everything but the projects which serve as inspiration and
the associated (updated) Linux kernel style guide link.

The checkpatch references are not particularly useful - the tool
exists in another (massive) git repo, plus we're using clang-format.

Plus the line wrapping details are already listed a few lines below.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/417
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agoCODING-STYLE.md: convert to markdown
Emil Velikov [Wed, 28 Jan 2026 19:50:20 +0000 (19:50 +0000)] 
CODING-STYLE.md: convert to markdown

Convert to markdown adding respective sections, heading and TOC.
Contents will be updated separately.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/417
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agoCONTRIBUTING.md: less "you", use calmer style
Emil Velikov [Wed, 28 Jan 2026 19:17:07 +0000 (19:17 +0000)] 
CONTRIBUTING.md: less "you", use calmer style

While initially writing this file, I didn't quite realise how much it
was trying to reach out and point back at the reader.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/417
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agoCONTRIBUTING.md: mellow down bugs/regressions section
Emil Velikov [Wed, 28 Jan 2026 19:16:21 +0000 (19:16 +0000)] 
CONTRIBUTING.md: mellow down bugs/regressions section

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/417
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agoCONTRIBUTING.md: some shell completions have landed
Emil Velikov [Wed, 28 Jan 2026 19:14:05 +0000 (19:14 +0000)] 
CONTRIBUTING.md: some shell completions have landed

... update the document to reflect that.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/417
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agoCONTRIBUTING.md: embed the DCO
Emil Velikov [Wed, 28 Jan 2026 18:57:26 +0000 (18:57 +0000)] 
CONTRIBUTING.md: embed the DCO

In the future, we might want to use the "reuse" tool to check/track
licensing information of the repo. For better or worse it will complain
that the in-tree DCO.txt is missing SPDX copyright/licensing
information.

It can be worked around, by adding it into a separate file. Although a
much simpler solution is to just inline it.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/417
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agoUse the SPDX `-or-later` license throughout
Emil Velikov [Wed, 28 Jan 2026 18:49:42 +0000 (18:49 +0000)] 
Use the SPDX `-or-later` license throughout

The shorthand `GPLv2+` and `LGPLv2.1+` got me as I was writing the meson
build, even though I was fully aware of the correct license.

Use the full SPDX identifier throughout the project - aka update the two
documents to align with the rest of the project.

Reference: ca9a7f4c ("build: Fix license specification")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/417
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agoman: remove outdated COPYRIGHT section
Emil Velikov [Mon, 10 Nov 2025 00:05:02 +0000 (00:05 +0000)] 
man: remove outdated COPYRIGHT section

While the section is fairly common (11.9k instances of 27.5k man pages
in my Arch install) it is not as ubiquitous as the rest.

Furthermore, the information is severely outdated.

Just remove it all together, instead of trying to devise some clever way
of managing it.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/400
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agoman: de-duplicate AUTHOR/BUGS sections
Emil Velikov [Sun, 9 Nov 2025 23:30:08 +0000 (23:30 +0000)] 
man: de-duplicate AUTHOR/BUGS sections

Move the sections into a dedicated trailer.scd file, which gets added
during manpage generation.

Note, that this removes the following text from kmod.8, which is
intentional:

*kmod* project was started by Lucas De Marchi as a drop-in replacement to
module-init-tools that was maintained by Jon Masters, adding a library (libkmod)
and additional features.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/400
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agoscripts/build-scdoc.sh: stop using cat
Emil Velikov [Sun, 9 Nov 2025 23:20:44 +0000 (23:20 +0000)] 
scripts/build-scdoc.sh: stop using cat

We don't need the cat + extra pipe - sed can take the input filename as
an argument.

This change is meant to ease de-duplication of the man pages - coming
with a later commit.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/400
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months ago.gitignore: remove majority of listings
Emil Velikov [Sun, 9 Nov 2025 21:47:09 +0000 (21:47 +0000)] 
.gitignore: remove majority of listings

With the move to meson. only out-of-tree builds are allowed. As such, we
can remove ~90% of the contents of our .gitignore file(s).

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/400
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agotestsuite: swap empty .gitignore for .gitkeep
Emil Velikov [Wed, 28 Jan 2026 16:59:01 +0000 (16:59 +0000)] 
testsuite: swap empty .gitignore for .gitkeep

Later commit will be removing some no longer needed .gitignore files
and/or contents.

In a few instances, we want the empty folder to be preserved so swap the
empty .gitignore for the more widely used and obvious (IMHO) .gitkeep.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/400
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agomeson: reuse f strings where possible
Emil Velikov [Sun, 9 Nov 2025 22:21:44 +0000 (22:21 +0000)] 
meson: reuse f strings where possible

With meson 0.61 we can use f strings, over the explicit .format().
Multi-line f-strings are introduced with meson 0.63, which we don't
require yet, plus it's not like we have many instances.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/400
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agoman: remove manual .so links
Emil Velikov [Sun, 9 Nov 2025 21:41:20 +0000 (21:41 +0000)] 
man: remove manual .so links

These are left overs from the autotools-side of the build system.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/400
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agomeson: use identical ln arguments internally
Emil Velikov [Thu, 29 Jan 2026 11:18:53 +0000 (11:18 +0000)] 
meson: use identical ln arguments internally

Update the internal symlinks to also use -r/--relative, just like the
installed ones.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/400
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agomeson: wrap the whole tools section inside an if block
Emil Velikov [Thu, 29 Jan 2026 11:13:16 +0000 (11:13 +0000)] 
meson: wrap the whole tools section inside an if block

At the moment, we leave random bits out of the `if get_option('tools')`
block (internal/static libkmod, kmod.pc and internal symlinks).

The latter of which, is annotated as build_by_default:true, which means
it always pulls the executable - kmod - and ultimatelly, we build all
tools related artefacts even with -Dtools=false.

Just wrap the whole section and simplify the executable() a bit. Namely:
use install: true and drop build_by_default.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/400
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agomeson: remove default install:false for static libs
Emil Velikov [Thu, 29 Jan 2026 11:08:17 +0000 (11:08 +0000)] 
meson: remove default install:false for static libs

The default for install is false... for static/shared libraries and
executables at least. The documentation for custom_target doesn't
specify.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/400
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agomeson: remove build_by_default instances in man/
Emil Velikov [Sun, 9 Nov 2025 23:12:01 +0000 (23:12 +0000)] 
meson: remove build_by_default instances in man/

With earlier meson versions (pre 0.50) build_by_default and install
didn't have great integration. With newer meson versions, as the former
is undefined the latter will control both.

More importantly, the whole meson.build is included only on
get_option('manpages').

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/400
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agoman: underline the module/file name in modinfo(8)
Emil Velikov [Sun, 9 Nov 2025 21:13:51 +0000 (21:13 +0000)] 
man: underline the module/file name in modinfo(8)

We do so in all other manual pages, so update the outlier.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/400
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agoman: remove inconsistent ellipsis
Emil Velikov [Sun, 9 Nov 2025 15:13:19 +0000 (15:13 +0000)] 
man: remove inconsistent ellipsis

In a number of places we are using ellipsis to indicate plural/multiple
instances. It's not fairly consistent plus we can live without them in
my opinion.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/400
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agormmod: s/list of modulenames/modulenames/
Emil Velikov [Sun, 9 Nov 2025 21:11:50 +0000 (21:11 +0000)] 
rmmod: s/list of modulenames/modulenames/

Drop the "list of" part - we are already (somewhat) consistently using
modulenames across the tree.

While in here, also drop the square brackets - the modulename(s) is not
an optional argument.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/400
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agoman: drop optional qualifiers for file/modulename
Ricardo Branco [Sun, 9 Nov 2025 14:57:53 +0000 (14:57 +0000)] 
man: drop optional qualifiers for file/modulename

Most tools don't consider the file/module name as optional, so we can
drop the square brackets denoting so.

Mind you, if we want to be extra pedantic - it is not required for
--help, --version et al. Although that should be obvious, as we are
(starting to) simplify yet enhance the documentation.

Signed-off-by: Ricardo Branco <rbranco@suse.de>
[Emil: drop kmod hunk, squash + commit message]
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/pull/400
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agomodprobe: don't attempt to remove an already removed module
Jan Stancek [Tue, 30 Sep 2025 08:37:21 +0000 (10:37 +0200)] 
modprobe: don't attempt to remove an already removed module

In a scenario like following:
    # lsmod | grep -e bnx2i -e cnic
    bnx2i                  94208  0
    libiscsi               94208  1 bnx2i
    cnic                   90112  1 bnx2i
    uio                    32768  1 cnic
    scsi_transport_iscsi   196608  2 bnx2i,libiscsi

    # modprobe -v --remove --remove-holders cnic
    rmmod bnx2i
    rmmod cnic
    rmmod libiscsi
    rmmod cnic
    modprobe: ERROR: libkmod/libkmod-module.c:856 kmod_module_remove_module()
    could not remove 'cnic': No such file or directory

modprobe attempts to remove cnic module twice and propagates that error
to the user with a message as well as an exit code.

Add a check to avoid attempts to remove modules that are already gone.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/pull/393
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agoshared: Use uint8_t in hash_superfast
Tobias Stoeckmann [Fri, 15 Nov 2024 17:41:22 +0000 (18:41 +0100)] 
shared: Use uint8_t in hash_superfast

Characters in key are supposed to be handled unsigned. Explicitly cast
key[2] in case the key contains 8-bit ASCII. Even though we cannot
support such keys in indices, we might still use them in module names
and tools like modinfo.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/pull/248
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agobuild: Fix license specification
Tobias Stoeckmann [Tue, 13 Jan 2026 17:16:38 +0000 (18:16 +0100)] 
build: Fix license specification

The kmod project actually uses LGPL 2.1 or later for libkmod. Clarify
this and use proper SPDX license identifier as done in source files.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Lucas De Marchi <demarchi@kernel.org>
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agoci: bump the all-actions group across 1 directory with 6 updates
dependabot[bot] [Thu, 1 Jan 2026 01:08:42 +0000 (01:08 +0000)] 
ci: bump the all-actions group across 1 directory with 6 updates

Bumps the all-actions group with 6 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [actions/checkout](https://github.com/actions/checkout) | `4.2.2` | `6.0.1` |
| [yshui/git-clang-format-lint](https://github.com/yshui/git-clang-format-lint) | `1.17` | `1.18` |
| [github/codeql-action](https://github.com/github/codeql-action) | `3.28.18` | `4.31.9` |
| [codespell-project/actions-codespell](https://github.com/codespell-project/actions-codespell) | `2.1` | `2.2` |
| [codecov/codecov-action](https://github.com/codecov/codecov-action) | `5.4.3` | `5.5.2` |
| [peter-evans/repository-dispatch](https://github.com/peter-evans/repository-dispatch) | `3` | `4` |

Updates `actions/checkout` from 4.2.2 to 6.0.1
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/11bd71901bbe5b1630ceea73d27597364c9af683...8e8c483db84b4bee98b60c0593521ed34d9990e8)

Updates `yshui/git-clang-format-lint` from 1.17 to 1.18
- [Release notes](https://github.com/yshui/git-clang-format-lint/releases)
- [Commits](https://github.com/yshui/git-clang-format-lint/compare/27f3890c6655216edadcc2759110b9c127c74786...0758f498e508097267c3f4d0827b2fefeb25cc9d)

Updates `github/codeql-action` from 3.28.18 to 4.31.9
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/ff0a06e83cb2de871e5a09832bc6a81e7276941f...5d4e8d1aca955e8d8589aabd499c5cae939e33c7)

Updates `codespell-project/actions-codespell` from 2.1 to 2.2
- [Release notes](https://github.com/codespell-project/actions-codespell/releases)
- [Commits](https://github.com/codespell-project/actions-codespell/compare/406322ec52dd7b488e48c1c4b82e2a8b3a1bf630...8f01853be192eb0f849a5c7d721450e7a467c579)

Updates `codecov/codecov-action` from 5.4.3 to 5.5.2
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/18283e04ce6e62d37312384ff67231eb8fd56d24...671740ac38dd9b0130fbe1cec585b89eea48d3de)

Updates `peter-evans/repository-dispatch` from 3 to 4
- [Release notes](https://github.com/peter-evans/repository-dispatch/releases)
- [Commits](https://github.com/peter-evans/repository-dispatch/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 6.0.1
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: all-actions
- dependency-name: yshui/git-clang-format-lint
  dependency-version: '1.18'
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-actions
- dependency-name: github/codeql-action
  dependency-version: 4.31.9
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: all-actions
- dependency-name: codespell-project/actions-codespell
  dependency-version: '2.2'
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-actions
- dependency-name: codecov/codecov-action
  dependency-version: 5.5.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-actions
- dependency-name: peter-evans/repository-dispatch
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: all-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
2 months agoci: Fix alpine setup
Lucas De Marchi [Fri, 16 Jan 2026 06:34:54 +0000 (00:34 -0600)] 
ci: Fix alpine setup

linux-edge-dev is failing in alpine:

ERROR: unable to select packages:
  linux-edge-dev (no such package):
    required by: world[linux-edge-dev]
Error: Process completed with exit code 1.

Use linux-stable instead.

Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
5 months agoci: swap bullseye for bookworm
Emil Velikov [Sun, 26 Oct 2025 12:27:48 +0000 (12:27 +0000)] 
ci: swap bullseye for bookworm

The former has been EOL for a bit now and somewhat recently has been
(re)moved from the repos -> our CI was failing.

Swap for bookworm, which gives us the "try a slightly older distro"
coverage, while still being green in CI.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/395
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
8 months agotestsuite: Fix build with gcc < 15
Lucas De Marchi [Fri, 11 Jul 2025 15:53:53 +0000 (10:53 -0500)] 
testsuite: Fix build with gcc < 15

Variable declaration inside a switch case works with gcc 15, but fails
pretty much everywhere else with a message like below:

../testsuite/init_module.c: In function â€˜syscall’:
../testsuite/init_module.c:343:3: error: a label can only be part of a statement and a declaration is not a statement
  343 |   const char *args;
      |   ^~~~~

Add an empty statement to fix it.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/390
8 months agotestsuite: simplify syscall number handling
Lucas De Marchi [Tue, 8 Jul 2025 12:38:58 +0000 (07:38 -0500)] 
testsuite: simplify syscall number handling

Use a switch() statement for syscall override handling, making it a
little bit less verbose.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/387
8 months agotestsuite/init_module: Handle __NR_riscv_hwprobe in syscall wrapper
Andreas Schwab [Sun, 29 Jun 2025 10:09:25 +0000 (12:09 +0200)] 
testsuite/init_module: Handle __NR_riscv_hwprobe in syscall wrapper

The libcrypto library constructor calls the riscv_hwprobe syscall through
the syscall wrapper.  Return an error with ENOSYS.

Signed-off-by: Andreas Schwab <schwab@suse.de>
Link: https://github.com/kmod-project/kmod/pull/387
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
9 months agotestsuite: consolidate final exit() call
Emil Velikov [Mon, 16 Jun 2025 20:41:14 +0000 (21:41 +0100)] 
testsuite: consolidate final exit() call

Currently we call exit() in a handful of places within test_run_child().
Where the latter is annotated as `noreturn int` and we never check the
return value.

Just move the exit() further up the call stack and remove the noreturn
notation.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/376
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotestsuite: fixup argument handling
Emil Velikov [Mon, 16 Jun 2025 16:00:42 +0000 (17:00 +0100)] 
testsuite: fixup argument handling

Currently we can pass any number of tests as arguments - be that in
oneshot mode or not.

At the same time, oneshot requires only one test while normal mode can
have up-to one.

Fix that up and as a bonus we no longer need the exit() in
test_run_spawned() \o/

While in here, add a few comments around our arg/argc handling.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/376
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotestsuite: remove struct test alignment
Emil Velikov [Mon, 16 Jun 2025 20:48:31 +0000 (21:48 +0100)] 
testsuite: remove struct test alignment

Remove the alignment from the struct declaration. The macro
instantiating it DEFINE_TEST_WITH_FUNC already has (proper) alignment.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/376
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agoRemove _always_inline_ attribute
Emil Velikov [Mon, 16 Jun 2025 20:52:16 +0000 (21:52 +0100)] 
Remove _always_inline_ attribute

We have a single _always_inline_ instance in-tree, which lives in a
header file. Just make it a "static inline", which will practically do
the same thing and what we already have elsewhere in-tree.

While in there drop the CAPS from ALIGN_POWER2 - it's a function, so we
don't need the shouting.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/376
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agoGlobally silence all Wattribute warnings
Emil Velikov [Mon, 16 Jun 2025 17:10:08 +0000 (18:10 +0100)] 
Globally silence all Wattribute warnings

Instead of playing a game of whack-a-mole, disable any -Wattribute
warnings globally. This means, people won't get the warnings when
building with older compilers which lack certain attributes.

Thus we can remove the _Pragma. With that gone, we no longer need the
clang-format off segment.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/376
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotestsuite: Fix build warning on kernel 6.15
Lucas De Marchi [Mon, 7 Jul 2025 16:42:41 +0000 (11:42 -0500)] 
testsuite: Fix build warning on kernel 6.15

The module description is now required, otherwise a warning is emitted
by modpost:

WARNING: modpost: missing MODULE_DESCRIPTION() in mod-loop-k.o

Fix all of them with:

sed -i '/MODULE_LICENSE("LGPL");/a MODULE_DESCRIPTION("dummy test module");' testsuite/module-playground/mod-*.c
sed -i '/MODULE_LICENSE("GPL");/a MODULE_DESCRIPTION("dummy test module");' testsuite/module-playground/mod-simple.c

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agoci: Use KDIR=any
Lucas De Marchi [Fri, 27 Jun 2025 17:13:12 +0000 (12:13 -0500)] 
ci: Use KDIR=any

Drop .github/print-kdir.sh and just use KDIR=any to handle the kernel
headers.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/384
9 months agotestsuite: Handle KDIR=any
Lucas De Marchi [Fri, 27 Jun 2025 17:01:15 +0000 (12:01 -0500)] 
testsuite: Handle KDIR=any

I update my kernel frequently and may not be running a kernel with
headers installed. That always leads me to:

1) run `meson test -C build`
2) Oh, crap, it fails: no kernel headers
3) Find whatever kernel header is installed and point KDIR to it

We can do better and tell KDIR=any to use whatever it finds.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/384
9 months agoutil: Use local variable in get_backoff_delta_msec
Tobias Stoeckmann [Sun, 29 Jun 2025 11:40:46 +0000 (13:40 +0200)] 
util: Use local variable in get_backoff_delta_msec

This might make the code easier to read.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/377
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agomodprobe: return error on timeout
Tobias Stoeckmann [Thu, 19 Jun 2025 16:44:51 +0000 (18:44 +0200)] 
modprobe: return error on timeout

If module cannot be removed in time, return with a failure, not success:

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/377
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotestsuite: add test for get_backoff_delta_msec
Emil Velikov [Thu, 19 Jun 2025 16:41:22 +0000 (18:41 +0200)] 
testsuite: add test for get_backoff_delta_msec

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/377
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agoutil: check for overflow in get_backoff_delta_msec
Tobias Stoeckmann [Sun, 29 Jun 2025 11:17:22 +0000 (13:17 +0200)] 
util: check for overflow in get_backoff_delta_msec

If a large delta is given, the multiplication might overflow.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/377
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agoutil: fix endless loop in get_backoff_delta_msec
Tobias Stoeckmann [Sun, 29 Jun 2025 11:13:34 +0000 (13:13 +0200)] 
util: fix endless loop in get_backoff_delta_msec

If current time t is already past tend, the while loop in
get_backoff_delta_msec never ends.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/377
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agoci: move compression variants further down
Emil Velikov [Mon, 16 Jun 2025 23:37:52 +0000 (00:37 +0100)] 
ci: move compression variants further down

Move the variants into their own section, similar to the moduledir and
co. This bears no functional change in the CI run.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/383
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agoci: remove default options from Debian/bullseye build
Emil Velikov [Mon, 16 Jun 2025 23:34:24 +0000 (00:34 +0100)] 
ci: remove default options from Debian/bullseye build

Both -Dopenssl=enabled and -Dtools=true are the default. Omit them from
the meson_setup.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/383
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agoci: 'temporary' disable sanitizers for 32bit builds
Emil Velikov [Mon, 16 Jun 2025 23:30:40 +0000 (00:30 +0100)] 
ci: 'temporary' disable sanitizers for 32bit builds

Currently running 32bit tests alongside sanitizers, segfaults due to our
syscall wrapper. Just disable the sanitizers, which means we get at
least some 32bit test coverage.

On a couple of attempts, I wasn't able to get a proper/robust solution,
as outlined in init_module.c - we need vsyscall() which does not exist.

Considering some distributions are dropping 32bit/i686 support, it may
be that we'll nuke these builds from CI sooner than later.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/383
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agoCONTRIBUTING.md: make it common markdown compatible
Emil Velikov [Sat, 21 Jun 2025 10:13:15 +0000 (11:13 +0100)] 
CONTRIBUTING.md: make it common markdown compatible

Adjust the markdown variant, so it renders correctly in both GitHub and
cgit (... vim also seems happier fwiw). AFAICT the latter is using
CommonMarkdown as handled by python-markdown.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/380
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agoREADME.md: make it common markdown compatible
Emil Velikov [Sat, 21 Jun 2025 10:09:50 +0000 (11:09 +0100)] 
README.md: make it common markdown compatible

Adjust the markdown variant, so it renders correctly in both GitHub and
cgit (... vim also seems happier fwiw). AFAICT the latter is using
CommonMarkdown as handled by python-markdown.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/380
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotestsuite/test-modprobe: reinstate chdir error path
Emil Velikov [Fri, 20 Jun 2025 10:11:04 +0000 (11:11 +0100)] 
testsuite/test-modprobe: reinstate chdir error path

Earlier commit used a global sed to remove the no-longer needed
exit(EXIT_FAILURE) calls. In the process it also removed one instance
in the error path, which should remain.

Fixes: e09acf2e ("testsuite: remove exit from EXEC_TOOL tests")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/379
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agolibkmod/README: fix grammar
Tobias Stoeckmann [Thu, 19 Jun 2025 16:54:54 +0000 (18:54 +0200)] 
libkmod/README: fix grammar

Co-authored-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/378
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotestsuite: remove exit() calls from main()
Emil Velikov [Fri, 13 Jun 2025 16:45:34 +0000 (17:45 +0100)] 
testsuite: remove exit() calls from main()

There is no particular reason for us to use exit(), so just avoid it.

As result, the only instances using of exit() are within the child
process and our cleanup is complete :-)

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/371
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotestsuite: always exit() from the child process
Emil Velikov [Fri, 13 Jun 2025 16:45:34 +0000 (17:45 +0100)] 
testsuite: always exit() from the child process

Update the existing code-paths to always exit() for the child process.
We already handle that in a few places, but the error-paths are
(understandably) off.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/371
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotestsuite: remove remaining exit/noreturn instances
Emil Velikov [Fri, 13 Jun 2025 16:37:25 +0000 (17:37 +0100)] 
testsuite: remove remaining exit/noreturn instances

Purge the remaining exit/noreturn instances, which means we now get a
consistent return path on all tests and across both success and failure
paths.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/371
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotestsuite: remove exit from EXEC_TOOL tests
Emil Velikov [Fri, 13 Jun 2025 16:24:32 +0000 (17:24 +0100)] 
testsuite: remove exit from EXEC_TOOL tests

The EXEC_TOOL macros calls test_spawn_prog() which returns EXIT_FAILURE
in the unlikely case of a return from execv().

Thus the explicit exit() is dead code that we can remove and alongside
it the noreturn notation of the respective tests.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/371
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotestsuite: introduce and use EXEC_TOOL() macro
Emil Velikov [Fri, 13 Jun 2025 16:16:09 +0000 (17:16 +0100)] 
testsuite: introduce and use EXEC_TOOL() macro

Swap the currect EXEC_DEPMOD and EXEC_MODPROBE with a slightly more
generic macro - EXEC_TOOL based off them.

Update all in-tree instances of test_spawn_prog() to use it.

This will make follow-up work (removing the noreturn/exit) a bit easier
and more consistent.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/371
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotestsuite/test-remove: plug memory leaks in success path
Emil Velikov [Fri, 13 Jun 2025 19:12:28 +0000 (20:12 +0100)] 
testsuite/test-remove: plug memory leaks in success path

With the upcoming patches, removing exit() usage, ASan started reporting
that our test leaks kmod_module handles.

Resolve those leaks - we shouldn't be doing that in the normal (success)
path.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/371
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotestsuite/test-init: plug memory leaks in success path
Emil Velikov [Fri, 13 Jun 2025 19:12:28 +0000 (20:12 +0100)] 
testsuite/test-init: plug memory leaks in success path

With the upcoming patches, removing exit() usage, ASan started reporting
that our test leaks kmod_module handles.

Resolve those leaks - we shouldn't be doing that in the normal (success)
path.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/371
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotestsuite: use ARRAY_SIZE() for iteration
Emil Velikov [Fri, 13 Jun 2025 18:48:18 +0000 (19:48 +0100)] 
testsuite: use ARRAY_SIZE() for iteration

Currently we use a mix of ARRAY_SIZE() and iterator pointer, where the
latter needs an extra instance for the NULL sentinel. Plus as evidenced
by the EXIT_SUCCESS -> EXIT_FAILURE changes in test-new-module - is
error prone.

Consistently use ARRAY_SIZE(), fixing the logical error in the test
which was flagged by ASan as memory leak :-)

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/371
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotestsuite: static const annotate the remaining test data
Emil Velikov [Fri, 13 Jun 2025 18:44:25 +0000 (19:44 +0100)] 
testsuite: static const annotate the remaining test data

A while ago we annotated a bunch of of the tests although I missed some
during grepping. Update the final instances, taking the chance to move
the strdup instances into the test loop and failing the test should the
duplication fails.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/371
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotools/modprobe: --dry-run shouldn't need -v
Lucas De Marchi [Fri, 13 Jun 2025 19:11:08 +0000 (14:11 -0500)] 
tools/modprobe: --dry-run shouldn't need -v

Make sure it shows something when running in dry-run mode.

Before:
kmod $ lsmod | grep i915
kmod $ ./build/modprobe --dry-run i915
kmod $ ./build/modprobe -v --dry-run i915
insmod /lib/modules/6.14.11-1-MANJARO/kernel/drivers/char/agp/intel-gtt.ko.zst
insmod /lib/modules/6.14.11-1-MANJARO/kernel/drivers/gpu/drm/i915/i915.ko.zst

After:
kmod $ lsmod | grep i915
kmod $ ./build/modprobe --dry-run i915
insmod /lib/modules/6.14.11-1-MANJARO/kernel/drivers/char/agp/intel-gtt.ko.zst
insmod /lib/modules/6.14.11-1-MANJARO/kernel/drivers/gpu/drm/i915/i915.ko.zst

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/372
9 months agotools/modprobe: Fix odd --remove-holders behavior
Lucas De Marchi [Fri, 13 Jun 2025 18:57:08 +0000 (13:57 -0500)] 
tools/modprobe: Fix odd --remove-holders behavior

--remove-holders was not implying --remove, which means that if the user
called `modprobe --remove-holders xe` it would actually try to insert
the xe module. Fix it and spell it out in the man page about one option
implying the other.

Considering i915 is not currently loaded:

Before:
kmod $ ./build/modprobe -v --dry-run --remove-holders i915
insmod /lib/modules/6.14.11-1-MANJARO/kernel/drivers/char/agp/intel-gtt.ko.zst
insmod /lib/modules/6.14.11-1-MANJARO/kernel/drivers/gpu/drm/i915/i915.ko.zst
kmod $

After:
kmod $ ./build/modprobe -v --dry-run --remove-holders i915
kmod $

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/372
9 months agoman/modprobe.8: Remove needless **
Lucas De Marchi [Fri, 13 Jun 2025 17:45:31 +0000 (12:45 -0500)] 
man/modprobe.8: Remove needless **

There are 2 too many * to document the `-r` option.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/372
9 months agoci: remove Alpine -Ddocs=false WA
Emil Velikov [Mon, 16 Jun 2025 06:32:06 +0000 (07:32 +0100)] 
ci: remove Alpine -Ddocs=false WA

A while ago the Alpine gtk-doc tool chain was having issues building our
docs. That got resolved at some point over the past months, so we can
drop this local workaround.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/373
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotools/modprobe: accept module name with --show-modversions
Emil Velikov [Mon, 19 May 2025 20:08:26 +0000 (21:08 +0100)] 
tools/modprobe: accept module name with --show-modversions

Use the newly introduced helper module_new_from_any(), so we accept both
files as well as modules. This means you can now do:
 - modprobe --show-modversions drm-vram-helper, alongside the existing
 - modprobe --show-modversions /full/path/to/the/module/drm_vram_helper.ko

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/353
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotestsuite/modprobe: add modprobe --show-exports modulename
Emil Velikov [Fri, 30 May 2025 19:16:11 +0000 (20:16 +0100)] 
testsuite/modprobe: add modprobe --show-exports modulename

Add test for the newly introduced --show-exports code path.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/353
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotestsuite/modprobe: remove --quiet from --show-{depends,exports}
Emil Velikov [Fri, 30 May 2025 19:10:09 +0000 (20:10 +0100)] 
testsuite/modprobe: remove --quiet from --show-{depends,exports}

Even though we don't give the user any feedback, the --quiet option is
only applicable with --remove. Remove it from any modprobe --show*
invocations.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/353
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotools/modprobe: accept module name with --show-exports
Emil Velikov [Mon, 19 May 2025 20:08:26 +0000 (21:08 +0100)] 
tools/modprobe: accept module name with --show-exports

Use the newly introduced helper module_new_from_any(), so we accept both
files as well as modules. This means you can now do:
 - modprobe --show-exports drm-vram-helper, alongside the existing
 - modprobe --show-exports /full/path/to/the/module/drm_vram_helper.ko

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/353
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotools/modprobe: factor out module_new_from_any()
Emil Velikov [Mon, 19 May 2025 19:54:33 +0000 (20:54 +0100)] 
tools/modprobe: factor out module_new_from_any()

Split the functionality into a helper function, which will be used with
later commits.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/353
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agoman/modprobe.8: document --show-exports
Emil Velikov [Fri, 30 May 2025 18:23:04 +0000 (19:23 +0100)] 
man/modprobe.8: document --show-exports

The option was introduced a few years ago, yet the manual page went
without an update. Add some basic documentation.

Cc: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Fixes: 3ada8df8 ("modprobe: add --show-exports")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/353
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotools/modprobe: standardize on --show-foo, deprecate the rest
Emil Velikov [Fri, 30 May 2025 18:11:48 +0000 (19:11 +0100)] 
tools/modprobe: standardize on --show-foo, deprecate the rest

Currently we have a range of options which show specific details,
although they vary in prefix or spelling:
 - prefix: dump vs resolve vs show
 - with and without dash after show

Converge on --show-foo and deprecate the rest. The old options are still
accepted but will throw a warning. Only the (new) consistent names are
listed in --help, while the manual page lists both but spells out that
the old ones will be removed.

To avoid any confusion with --show (aka --dry-run) the option is also
soft-deprecated.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/353
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotools/modprobe: properly deprecate --remove-dependencies
Emil Velikov [Fri, 13 Jun 2025 15:34:22 +0000 (16:34 +0100)] 
tools/modprobe: properly deprecate --remove-dependencies

The option was annotated as deprecated a while ago, although we never
flagged a warning when it is in use.

Do that, remove it from the --help screen and add an explicit "will be
removed" notice in the manual page.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/353
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agoman/modprobe.8: document --remove-holders
Emil Velikov [Fri, 30 May 2025 18:23:04 +0000 (19:23 +0100)] 
man/modprobe.8: document --remove-holders

The option was introduced a few years ago, yet the manual page went
without an update. Add some basic documentation.

Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Fixes: 42b32d30 ("modprobe: Fix holders removal")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/353
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotools/static-nodes: don't use %m on mkdir_parents() failure
Emil Velikov [Wed, 4 Jun 2025 16:16:25 +0000 (17:16 +0100)] 
tools/static-nodes: don't use %m on mkdir_parents() failure

The function returns the error code itself, so we should be using
strerror(-err) instead.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/368
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotools/depmod: don't use %m on kmod_new() failure
Emil Velikov [Wed, 4 Jun 2025 16:16:25 +0000 (17:16 +0100)] 
tools/depmod: don't use %m on kmod_new() failure

The KMOD API returns NULL on error and getting the exact means why it
failed is undefined. In practise the errno is set in _some_ of the error
paths, but not all.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/368
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotools/depmod: don't use %m on mkdir_p() failure
Emil Velikov [Wed, 4 Jun 2025 16:16:25 +0000 (17:16 +0100)] 
tools/depmod: don't use %m on mkdir_p() failure

The function returns the error code itself, so we should be using
strerror(-err) instead.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/368
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotools/depmod: explicitly return ENOMEM on hash_new() failure
Emil Velikov [Wed, 4 Jun 2025 16:16:25 +0000 (17:16 +0100)] 
tools/depmod: explicitly return ENOMEM on hash_new() failure

The function will always set errno of ENOMEM, so we might as well use
that. Making the code more consistent and removing a few bytes/LoC.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/368
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agotestsuite/test-{init,remove}: don't use %m with kmod API
Emil Velikov [Wed, 4 Jun 2025 16:16:25 +0000 (17:16 +0100)] 
testsuite/test-{init,remove}: don't use %m with kmod API

The kmod API returns the error code directly, which one should be used
alongside strerror(). Using %m may return a different result all
together.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/368
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agolibkmod: don't use %m on read_str_ulong() failure
Emil Velikov [Wed, 4 Jun 2025 16:16:25 +0000 (17:16 +0100)] 
libkmod: don't use %m on read_str_ulong() failure

The function returns the actual error itself, identically to the signed
variant - read_str_long(). Unlike the signed variant, one of ulong's
users incorrectly uses %m instead of strerror(-err).

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/368
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agolibkmod: don't use %m on strbuf_to_vector() failure
Emil Velikov [Wed, 4 Jun 2025 16:16:25 +0000 (17:16 +0100)] 
libkmod: don't use %m on strbuf_to_vector() failure

The function does not set the errno on overflow conditions, so the ERR()
will produce (somewhat) arbitrary strerror. Similar to other places
throughout the code base - just use ENOMEM.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/368
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agolibkmod: readback errno before calling kmod_log()
Emil Velikov [Wed, 4 Jun 2025 16:16:25 +0000 (17:16 +0100)] 
libkmod: readback errno before calling kmod_log()

Majority of our code-base reads back errno before calling the kmod_log()
to print an error, info or debug message.

Correct the last instances for consistency sake.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/368
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agolibkmod: explicitly return ENOMEM on kmod_module_*_new failure
Emil Velikov [Wed, 4 Jun 2025 16:16:25 +0000 (17:16 +0100)] 
libkmod: explicitly return ENOMEM on kmod_module_*_new failure

All these functions do is malloc() the respective struct and initialize
the members. The errno can only be ENOMEM, so just return it directly.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/368
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agoUse explicit ENOMEM when {m,re}alloc fails
Emil Velikov [Wed, 4 Jun 2025 16:16:25 +0000 (17:16 +0100)] 
Use explicit ENOMEM when {m,re}alloc fails

Currently our codebase has a mix of explicitly using ENOMEM and
propagating the errno... The latter of which is guaranteed to be ENOMEM
as documented in the manual pages.

Consolidate on ENOMEM, both for consistency sake and to remove a few
bytes off our binaries ;-)

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/368
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agolibkmod: return ENOMEM when strbuf_pushchar(s) fails
Emil Velikov [Wed, 4 Jun 2025 16:16:25 +0000 (17:16 +0100)] 
libkmod: return ENOMEM when strbuf_pushchar(s) fails

Currently get_strings() assumes that errno is set when either function
fails. This is not the case when our overflow checks kick in. The other
case where these functions fail is memory exhaustion.

In practice we cannot do anything if either of those trigger, plus I
don't see a compelling reason to set errno to EOVERFLOW... Something
which other parts of the codebase don't do.

So let's just return ENOMEM and avoid the corner case of returning
success from get_strings(), when it should be failing.

Fixes: 1005e99e ("libkmod: refactor builtin module handling")
Fixes: 952bf223 ("strbuf: Add strbuf_reserve_extra()")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/368
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
9 months agoRemove unused errno.h include
Emil Velikov [Wed, 4 Jun 2025 16:16:25 +0000 (17:16 +0100)] 
Remove unused errno.h include

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/368
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>