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>
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.
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>
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>
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>
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>
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)
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>
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>
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.
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
# 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>
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.
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>
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;
| ^~~~~
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>
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.
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.
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.
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>
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.
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.
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.
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>
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>
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.
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 :-)
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.
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.
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.
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
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
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.
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>
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.
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).
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.
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 ;-)
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>