]> git.ipfire.org Git - thirdparty/kmod.git/log
thirdparty/kmod.git
6 weeks 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>
6 weeks 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>
6 weeks 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>
6 weeks 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>
6 weeks 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>
6 weeks 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>
7 weeks 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>
7 weeks 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>
7 weeks 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>
7 weeks 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>
7 weeks 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>
7 weeks 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>
7 weeks 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>
7 weeks 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>
7 weeks 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>
7 weeks 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>
7 weeks 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>
7 weeks 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>
7 weeks agotestsuite/test-util: add extra get_backoff_delta_msec iteration
Emil Velikov [Fri, 30 May 2025 10:21:32 +0000 (11:21 +0100)] 
testsuite/test-util: add extra get_backoff_delta_msec iteration

Add an extra test to check delta does not exceed the upper boundary.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/361
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
7 weeks agoshared/util: remove unused t0 in get_backoff_delta_msec()
Emil Velikov [Thu, 29 May 2025 14:31:36 +0000 (15:31 +0100)] 
shared/util: remove unused t0 in get_backoff_delta_msec()

The argument was unused ever since the function was introduced - remove
it.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/361
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
7 weeks agotools/static-nodes: silence unused parameter warning
Emil Velikov [Thu, 29 May 2025 14:31:36 +0000 (15:31 +0100)] 
tools/static-nodes: silence unused parameter warning

The function signature for our printers is uniform, even though in one
of the instances a parameter is unused. There is not much we can do
here, just silence the compiler warning.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/361
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
7 weeks agotools/modprobe: initialize msec variables as needed
Emil Velikov [Thu, 29 May 2025 14:31:36 +0000 (15:31 +0100)] 
tools/modprobe: initialize msec variables as needed

Remove the initialization for interval_msec and tend_msec. They are set
on the first iteration... Assuming the user has set non-zero wait time.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/361
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
7 weeks agotools/kmod: silence unused parameter warnings
Emil Velikov [Thu, 29 May 2025 14:31:36 +0000 (15:31 +0100)] 
tools/kmod: silence unused parameter warnings

kmod_help() does not use neither argc nor argv although due to the
dispatch mechanism they are part of the function signature.

Not much we can do here - silence the compiler warnings.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/361
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
7 weeks agotools/depmod: remove unused parameter struct depmod
Emil Velikov [Thu, 29 May 2025 14:31:36 +0000 (15:31 +0100)] 
tools/depmod: remove unused parameter struct depmod

In a handful of functions we don't need the depmod struct. Remove it,
making the compiler happy and shaving a few bytes off the resulting
binary.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/361
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
7 weeks agotestsuite/test-hash: silence unused parameter warning
Emil Velikov [Thu, 29 May 2025 14:31:36 +0000 (15:31 +0100)] 
testsuite/test-hash: silence unused parameter warning

The implementation of our "hash_free" function varies in that the hash
data itself is not freed. Thus the function argument is unused, leading
to annoying compiler warning. Since there is nothing to be done here,
just silence it.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/361
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
7 weeks agotestsuite/{init,delete}_module: add TODOs for args validation
Emil Velikov [Thu, 29 May 2025 14:31:36 +0000 (15:31 +0100)] 
testsuite/{init,delete}_module: add TODOs for args validation

Currently we pass arguments to our *_module wrappers, which are lacking
any validation. Add a few TODO notes and silence the unused argument
compiler warnings.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/361
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
7 weeks agotestsuite/init_module: remove unused argument
Emil Velikov [Thu, 29 May 2025 14:31:36 +0000 (15:31 +0100)] 
testsuite/init_module: remove unused argument

Ever since write_one_line_file() was introduced, it never really
used its len argument. It's dead code, so just remove it.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/361
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
7 weeks agotestsuite: remove unused parameters
Emil Velikov [Thu, 29 May 2025 14:31:36 +0000 (15:31 +0100)] 
testsuite: remove unused parameters

As of previous commit, neither fd_cmp_regex nor fd_cmp_exact needs the
test fixture. Remove the unused parameter and make the compiler happy
;-)

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/361
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
7 weeks agotestsuite: remove unused struct test::print_outputs
Emil Velikov [Thu, 29 May 2025 14:31:36 +0000 (15:31 +0100)] 
testsuite: remove unused struct test::print_outputs

None of our tests use it, plus it's inconsistently handled - plain
comparison honours it, regex comparison does not.

In addition, on test failure the expected/actual values are always
printed. So we're not missing anything (too) critical here.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/361
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
7 weeks agotestsuite: stop passing struct test to the test itself
Emil Velikov [Thu, 29 May 2025 14:31:36 +0000 (15:31 +0100)] 
testsuite: stop passing struct test to the test itself

None of our tests require the test fixture details. Stop passing it into
the test function itself.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/361
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
7 weeks agolibkmod: silence unused param warnings for kmod_file_load_*() stubs
Emil Velikov [Fri, 30 May 2025 10:52:27 +0000 (11:52 +0100)] 
libkmod: silence unused param warnings for kmod_file_load_*() stubs

When building without compression, the respective load functions are
static inline header stubs. In which case the struct kmod_file *file is
always unused and the compiler rightfully warns about it.

Not much we can do here, other than annotate them to silence the
warnings.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/361
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
7 weeks agolibkmod: add TODO for module hashkey handling
Emil Velikov [Thu, 29 May 2025 14:31:36 +0000 (15:31 +0100)] 
libkmod: add TODO for module hashkey handling

We currently "leak" the hashkey handling in a few places. As result we
ignore the name passed to kmod_module_new().

Add a TODO entry and silence the unused parameter compiler warning.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/361
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
7 weeks agoshared: properly __attribute__ all macros
Emil Velikov [Fri, 30 May 2025 10:00:13 +0000 (11:00 +0100)] 
shared: properly __attribute__ all macros

Handful of the attributes were missing the trailing double underscore.
Thus they were not picked by our git grep combo and ultimately missing
from .clang-format.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/361
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
7 weeks agoshared/macro: avoid nesting macros where possible
Emil Velikov [Tue, 3 Jun 2025 18:00:49 +0000 (19:00 +0100)] 
shared/macro: avoid nesting macros where possible

Always try to use the attribute notation, so that we can reliably
collect all the macros in our .clang-format.

In the process, we can remove some (no longer used) macros.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/361
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
7 weeks agoclang-format: update attribute macros
Emil Velikov [Tue, 3 Jun 2025 17:55:03 +0000 (18:55 +0100)] 
clang-format: update attribute macros

Use the command to update the attribute macros list. Seemingly we've
updated the list manually, which meant that a) some symbols were not
annotated the expected way and b) some macros were not picked up.

First we start with auto-generating the list, the other issues will be
handled as follow-ups.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/361
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
8 weeks agoci: fold gcc/clang combinations together
Emil Velikov [Tue, 3 Jun 2025 21:46:48 +0000 (22:46 +0100)] 
ci: fold gcc/clang combinations together

Instead of listing each combination on per-compiler basis, assume we
want both unless annotated otherwise.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/362
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
8 weeks agoci: fold 32 and 64 bit jobs together
Emil Velikov [Tue, 3 Jun 2025 21:46:48 +0000 (22:46 +0100)] 
ci: fold 32 and 64 bit jobs together

We currently construct a single container for each distro, which is
capable of running both 32 and 64 bit builds.

In addition, since we're meson only (which allows only out-of-tree
builds) we can do multiple builds for a given checkout.

As result we hammer the docker registry and distribution/package servers
a bit less.

Notes:
 - 32bit distcheck is disabled - not particularly interesting
 - 32bit tests are disabled for everyone - they are consistently failing

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/362
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
8 weeks agoci: install and use bash across the board
Emil Velikov [Tue, 3 Jun 2025 22:06:48 +0000 (23:06 +0100)] 
ci: install and use bash across the board

The upcoming CI rework will hard depend on some bash constructs. While
theoretically possible to make them dash compliant, I'm not sure it's
worth the effort. Just install bash and carry on.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/362
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
8 weeks agoci: use meson bla -C builddir/
Emil Velikov [Tue, 3 Jun 2025 21:46:47 +0000 (22:46 +0100)] 
ci: use meson bla -C builddir/

Use builddir/ as indicated in our README, which makes it obvious that
what the argument is. While there, remove a few instances of mkdir/cd -
meson and ninja can handle it themselves.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/362
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
8 weeks agoscripts/sanitizer-env.sh: remove incorrect $CC quotes
Emil Velikov [Fri, 23 May 2025 11:01:29 +0000 (12:01 +0100)] 
scripts/sanitizer-env.sh: remove incorrect $CC quotes

On Arch (at least) the shell chokes when the CC variable contains space,
for the given construct - $("$CC" foobar).

Since we variable is likely to contain the executable and arguments, the
quotation is wrong. Drop it and ultimately resolve the LD_PRELOAD
issues... That said, the tests still fail over here, segfault-ing in (or
due to) the LD_PRELOAD library init-modules.so.

Fixes: f5b4ff82 ("Add support for clang sanitizers")
Fixes: c7686797 ("scripts/sanitizer-env.sh: support new clang 19 DSO")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/365
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
8 weeks agoci: bump the all-actions group with 2 updates
dependabot[bot] [Sun, 1 Jun 2025 01:46:06 +0000 (01:46 +0000)] 
ci: bump the all-actions group with 2 updates

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

Updates `github/codeql-action` from 3.28.16 to 3.28.18
- [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/28deaeda66b76a05916b6923827895f2b14ab387...ff0a06e83cb2de871e5a09832bc6a81e7276941f)

Updates `codecov/codecov-action` from 5.4.2 to 5.4.3
- [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/ad3126e916f78f00edff4ed0317cf185271ccc2d...18283e04ce6e62d37312384ff67231eb8fd56d24)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.28.18
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-actions
- dependency-name: codecov/codecov-action
  dependency-version: 5.4.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Link: https://github.com/kmod-project/kmod/pull/366
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agotools/depmod: use nsec granularity when checking timestamps
Emil Velikov [Sat, 24 May 2025 15:10:11 +0000 (16:10 +0100)] 
tools/depmod: use nsec granularity when checking timestamps

Current code uses the POSIX.1-2001 stat::st_mtime which has one second
granularity. Considering the depmod execution time may be smaller, we
should be using the POSIX.1-2008 stat::st_mtim which has nano-second
granularity instead.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/359
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agoRemove dietlibc stat::st_mtim workaround
Emil Velikov [Sat, 24 May 2025 14:40:49 +0000 (15:40 +0100)] 
Remove dietlibc stat::st_mtim workaround

Some versions of dietlibc lack struct stat::st_mtim, which was
introduced with POSIX.1-2008.

Considering the slow development cycle of dietlibc (last three releases
are 2024, 2018 and 2013) and there's no popular user (nor one in CI) of
it, let's remove the workaround.

All the other runtimes that we target - glibc, bionic and musl - have
the struct member.

Iff needed we can reintroduce the workaround at a later stage alongside
a CI permutation.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/359
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agoREADME: update C runtime library section
Emil Velikov [Thu, 29 May 2025 09:26:29 +0000 (10:26 +0100)] 
README: update C runtime library section

Our readme lists uClibc which has been EOL for over a decade and
superseded by uClibc-ng. In addition, in one place our code-base tries
to support dietlibc for some pre POSIX.1-2008 functionality.

Explicitly list POSIX.1-2008 alongside the C runtime libraries, which
are known to work.

If your favourite C library does not work with kmod, feel free to send
us patches - plus ideally one which adds a CI action for us to test.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/359
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agoREADME: explicitly document compiler requirements
Emil Velikov [Thu, 29 May 2025 09:21:47 +0000 (10:21 +0100)] 
README: explicitly document compiler requirements

Document C11 + GNU extensions as the requirement, omitting the exact
list of extensions since it's quite a bit.

The minimum compiler versions are somewhat arbitrary - we don't check
for them, so your experience may vary. Patches to update the README, or
to make kmod more widely buildable are welcome.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/359
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agoscripts/setup-modules.sh: remove autotools w/a
Emil Velikov [Sat, 24 May 2025 16:22:27 +0000 (17:22 +0100)] 
scripts/setup-modules.sh: remove autotools w/a

With autotools one can do in and out of tree builds. Since we're meson
only these days, we can drop the in-tree path.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/356
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agoConvert most #ifdef HAVE_FOO checks to #if HAVE_FOO
Emil Velikov [Sat, 24 May 2025 15:21:18 +0000 (16:21 +0100)] 
Convert most #ifdef HAVE_FOO checks to #if HAVE_FOO

The former is somewhat error prone, since the pre-processor will
evaluate the presence of the define, which might have been omitted due
to wrong include or otherwise.

Swap for the other solution we already have in-tree - always set the
relevant define(s) and evaluate them numerically. That combined with
-Wundef means that we'll get meaningful compiler warning when we get
something wrong.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/356
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agocheck strtol/strtoul/strtoull results
Tobias Stoeckmann [Sun, 25 May 2025 08:22:09 +0000 (10:22 +0200)] 
check strtol/strtoul/strtoull results

The strto* family of functions may fail if the input string contains
a number which is too large for the designated data type. In such
cases, errno is set to ERANGE. Check for this error condition and if
subsequent casts would truncate the value.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/357
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agoRemove default initializer for static variables
Emil Velikov [Thu, 29 May 2025 08:30:58 +0000 (09:30 +0100)] 
Remove default initializer for static variables

The spec dictates that static variables are initialized to 0/NULL.
Remove the unnecessary explicit initialization - on older compilers this
sheds a few bytes off the data section of respective binaries.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/358
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agolibkmod: s/* const/*const/ style nitpick
Emil Velikov [Sat, 24 May 2025 18:18:27 +0000 (19:18 +0100)] 
libkmod: s/* const/*const/ style nitpick

Portion of the header is annotated as clang-format off, to prevent
unwanted over formatting by clang. At the same time, a few erroneous
spaces slipped in.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/358
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agotools: move a few more symbols to data.rel.ro
Emil Velikov [Sat, 24 May 2025 18:17:24 +0000 (19:17 +0100)] 
tools: move a few more symbols to data.rel.ro

Annotate the arrays (not the data) as constant, so the compiler can
store it in the RO segment.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/358
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agoshared: declare DECLARE_(DL,PTR)SYM as static
Emil Velikov [Sat, 24 May 2025 18:09:06 +0000 (19:09 +0100)] 
shared: declare DECLARE_(DL,PTR)SYM as static

Declare the symbol pointers as static, otherwise the compiler will add
them to the data section instead of bss.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/358
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agotools/depmod: remove set but unused timeval
Emil Velikov [Sat, 24 May 2025 15:03:08 +0000 (16:03 +0100)] 
tools/depmod: remove set but unused timeval

No longer needed since the introduction of tmpfile-util.

Fixes: aae48bc9 ("depmod: add tmpfile-util to generate temporary file")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/358
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agotestsuite/path: defer and inline get_rootpath()
Emil Velikov [Sat, 24 May 2025 12:23:09 +0000 (13:23 +0100)] 
testsuite/path: defer and inline get_rootpath()

In a handful of use-cases, we don't need to trap the respective libc
function. Although at that point we have already fetched the rootfs
environment variable.

Defer it until it's needed and in the process inline the function. As
result we have a) less duplication in the wrappers and b) the rootpath
handling is no longer split across multiple functions.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/355
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agotestsuite/path: defer dlsym() until needed
Emil Velikov [Sat, 24 May 2025 12:10:50 +0000 (13:10 +0100)] 
testsuite/path: defer dlsym() until needed

There is no point in fetching the symbol if we already know we don't
need it. Defer the get_libc_func() after get_rootpath() and trap_path().

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/355
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agotestsuite/path: cache the old dlsym() results
Emil Velikov [Sat, 24 May 2025 12:02:48 +0000 (13:02 +0100)] 
testsuite/path: cache the old dlsym() results

There is no need for us to repeatedly fetch the respective symbols.
Based on the static storage of _fn, this must have been the goal since
day 1.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/355
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agotestsuite: fprintf() + abort() when dlsym() returns NULL
Emil Velikov [Sat, 24 May 2025 11:57:11 +0000 (12:57 +0100)] 
testsuite: fprintf() + abort() when dlsym() returns NULL

Currently each of our three dlsym() instances behaves differently. From
seg-faulting, to abort() to assert(). Just use abort throughout, since
assert() is no-op when NDEBUG is defined.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/355
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agotestsuite: always use dlsym(RTLD_NEXT, ...)
Emil Velikov [Sat, 24 May 2025 11:50:15 +0000 (12:50 +0100)] 
testsuite: always use dlsym(RTLD_NEXT, ...)

It has been supported by glibc, musl and bionic for years - our
supported platforms.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/355
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agolibkmod: use strstartswith() over memcmp()
Emil Velikov [Sat, 24 May 2025 11:33:36 +0000 (12:33 +0100)] 
libkmod: use strstartswith() over memcmp()

In the cases where we have a string literal, we can use our helper
without adding performance overhead.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/354
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agotools: use strlen() for string literals
Emil Velikov [Sat, 24 May 2025 11:06:13 +0000 (12:06 +0100)] 
tools: use strlen() for string literals

Older compilers had struggles expanding strlen(string-literal) to a
constant compile time expression. Thus our code-base used sizeof() - 1
instead.

This has been resolved for years, so let's use the correct function.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/354
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agoshared: use strlen() for string literals
Emil Velikov [Sat, 24 May 2025 11:06:13 +0000 (12:06 +0100)] 
shared: use strlen() for string literals

Older compilers had struggles expanding strlen(string-literal) to a
constant compile time expression. Thus our code-base used sizeof() - 1
instead.

This has been resolved for years, so let's use the correct function.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/354
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agolibkmod: use strlen() for string literals
Emil Velikov [Sat, 24 May 2025 11:06:13 +0000 (12:06 +0100)] 
libkmod: use strlen() for string literals

Older compilers had struggles expanding strlen(string-literal) to a
constant compile time expression. Thus our code-base used sizeof() - 1
instead.

This has been resolved for years, so let's use the correct function. As
a bonus point, we can remove a few variable making the code tad easier
to follow.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/354
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agolibkmod: reuse streq/strstartswith() whenever possible
Emil Velikov [Fri, 23 May 2025 13:15:36 +0000 (14:15 +0100)] 
libkmod: reuse streq/strstartswith() whenever possible

Use our handy macro(s) for clarity and consistency sake.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/354
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agolibkmod: reuse strstartswith() whenever possible
Emil Velikov [Fri, 23 May 2025 13:15:36 +0000 (14:15 +0100)] 
libkmod: reuse strstartswith() whenever possible

Use our handy macro(s) for clarity and consistency sake.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/354
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agotestsuite: reuse streq() whenever possible
Emil Velikov [Fri, 23 May 2025 13:15:36 +0000 (14:15 +0100)] 
testsuite: reuse streq() whenever possible

Use our handy macro(s) for clarity and consistency sake.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/354
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agomeson: disable Wdeclaration-after-statement
Emil Velikov [Sat, 24 May 2025 16:40:47 +0000 (17:40 +0100)] 
meson: disable Wdeclaration-after-statement

Having declarations after statement is a C90 requirement, which was
relaxed with C99. While there are some arguments for having it enabled
in new code, there are benefits to the contrary which are more appealing
IMHO.

Namely, by keeping the declarations where the variables are used, better
outlines the scope, reduces chances of shadowing and helps us avoid
"unused variable" compiler warning in some paths.

Flip the warning to -Wno for now and future patches can remove some of
the workarounds we have in-tree.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/360
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agomeson: alpha sort -Wno section
Emil Velikov [Thu, 29 May 2025 09:53:12 +0000 (10:53 +0100)] 
meson: alpha sort -Wno section

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/360
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agotestsuite: modprobe: Add --force-{vermagic,modversion} tests
Rong Tao [Tue, 6 May 2025 10:57:17 +0000 (18:57 +0800)] 
testsuite: modprobe: Add --force-{vermagic,modversion} tests

We don't have any moversion/vermagic tests. This patch add testsuite
--force-{vermagic,modversion} for modprobe.

Link: https://github.com/kmod-project/kmod/pull/344
Signed-off-by: Rong Tao <rongtao@cestc.cn>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agolibkmod: update remaining function to return the error code
Emil Velikov [Wed, 7 May 2025 17:58:11 +0000 (18:58 +0100)] 
libkmod: update remaining function to return the error code

Rework the function signature and return the error code instead of the
stripped module. Thus we no longer explicitly set errno.

v2:
 - kmod_file_open() - use _cleanup_free_, return errno instead of ENOMEM

Reference: https://github.com/kmod-project/kmod/issues/244
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/346
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agolibkmod: return the errno from kmod_elf_new()
Emil Velikov [Wed, 7 May 2025 17:58:11 +0000 (18:58 +0100)] 
libkmod: return the errno from kmod_elf_new()

Rework the function signature and return the error code instead of the
stripped module. Thus we no longer explicitly set errno.

Reference: https://github.com/kmod-project/kmod/issues/244
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/346
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agolibkmod: kmod_file_get_contents() returns constant data
Emil Velikov [Wed, 7 May 2025 19:00:12 +0000 (20:00 +0100)] 
libkmod: kmod_file_get_contents() returns constant data

The function returns what is considered constant data and all the
callers handle it as such. Add the declaration to make things obvious.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/346
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agolibkmod: enforce non-null memory in kmod_elf_new()
Emil Velikov [Wed, 7 May 2025 18:50:06 +0000 (19:50 +0100)] 
libkmod: enforce non-null memory in kmod_elf_new()

In practise none of our code-paths will use a NULL pointer so we might
as well enforce that. To stay aligned with the kernel behaviour update
our init_module() preload library to return EFAULT... Should we get
confused and pass NULL in the future.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/346
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agolibkmod: return the errno from kmod_elf_strip()
Emil Velikov [Wed, 7 May 2025 17:58:11 +0000 (18:58 +0100)] 
libkmod: return the errno from kmod_elf_strip()

Rework the function signature and return the error code instead of the
stripped module. Thus we no longer explicitly set errno.

Reference: https://github.com/kmod-project/kmod/issues/244
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/346
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agolibkmod: remove getdelim() buffer null check
Emil Velikov [Wed, 7 May 2025 17:46:55 +0000 (18:46 +0100)] 
libkmod: remove getdelim() buffer null check

As per the manual getdelim(3):
   The buffer is null-terminated and ...

Remove the local check and inline the function call. As a nice result,
we no longer set the errno and the context of feof() is obvious.

Reference: https://github.com/kmod-project/kmod/issues/244
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/346
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agolibkmod: don't set errno in strbuf_to_vector()
Emil Velikov [Wed, 7 May 2025 13:20:29 +0000 (14:20 +0100)] 
libkmod: don't set errno in strbuf_to_vector()

The function does bounds checking, allocation and copying. In the first
instance, we manually set errno (to ENOMEM?) on failure. The realloc()
call does the same, implicitly.

In practice we don't distinguish between the two failures, so we might
as well stop manually setting errno and always assume ENOMEM in the
caller.

Reference: https://github.com/kmod-project/kmod/issues/244
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/346
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agotestsuite/init-module: error out init_module() on kmod failure
Emil Velikov [Wed, 7 May 2025 16:50:03 +0000 (17:50 +0100)] 
testsuite/init-module: error out init_module() on kmod failure

Currently our wrapper init_module() will happily return success whenever
libkmod fails. While such failures are unlikely, our wrapper should also
fail. In part so it doesn't mask a potentially deeper problem and in
part because the kmod API used, will set errno... Something a normal
syscall wouldn't do AFAICT.

v2:
 - remove the respective comment

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/346
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agolibkmod: return the errno from kmod_builtin_info_init()
Emil Velikov [Wed, 7 May 2025 13:13:39 +0000 (14:13 +0100)] 
libkmod: return the errno from kmod_builtin_info_init()

Change the function signature (bool -> int) and directly return the
error code. Thus we no longer need to overwrite errno.

v2:
 - return false -> return -ENAMETOOLONG

Reference: https://github.com/kmod-project/kmod/issues/244
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/346
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agotools/modinfo: return the errno from add_param()
Emil Velikov [Wed, 7 May 2025 12:22:41 +0000 (13:22 +0100)] 
tools/modinfo: return the errno from add_param()

The single caller of add_param() does not need the struct param*, so we
might as well return the error code directly. As a result we don't
manually overwrite errno.

Reference: https://github.com/kmod-project/kmod/issues/244
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/346
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agolibkmod: don't reset errno in kmod_file_load_zlib()
Emil Velikov [Wed, 7 May 2025 13:24:36 +0000 (14:24 +0100)] 
libkmod: don't reset errno in kmod_file_load_zlib()

Currently we reset errno, shortly to be followed by an fcntl() and
gzdopen() calls. Both of those should set errno on failure and preserve
it on success.

Just leave errno as-is, we shouldn't be changing it in this context.

Reference: https://github.com/kmod-project/kmod/issues/244
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/346
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agoshared: don't reset errno in read_str_{u,}long()
Emil Velikov [Wed, 7 May 2025 12:18:04 +0000 (13:18 +0100)] 
shared: don't reset errno in read_str_{u,}long()

Currently we reset errno prior to calling strto{u,}l(). This is not
needed, since a) we don't check errno to see if the function was
successful and b) we explicitly propagate the error code by returning it
directly to the caller.

Reference: https://github.com/kmod-project/kmod/issues/244
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/346
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agoUse %m over strerror(errno) where possible
Emil Velikov [Wed, 7 May 2025 12:04:25 +0000 (13:04 +0100)] 
Use %m over strerror(errno) where possible

The manual page of strerror() outlines a number of caveats wrt its usage.
Swap for the GNU specific %m printf modifier (also supported on musl and
bionic), which side-steps the issues as much as possible.

Co-authored-by: Cristian Rodríguez <cristian@rodriguez.im>
[emil: split from larger patch, convert more instances to %m]
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/346
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agolibkmod: fixup kmod_module_get_initstate() error reporting
Emil Velikov [Wed, 7 May 2025 12:10:42 +0000 (13:10 +0100)] 
libkmod: fixup kmod_module_get_initstate() error reporting

Currently, the function will report the exact same issue twice. Where
the second DBG() and the error code returned, should highlight the
(potential) stat(2) failure.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/346
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agolibkmod: Fix dependency count in kmod_module_parse_depline()
Yuntao Wang [Fri, 16 May 2025 11:11:02 +0000 (19:11 +0800)] 
libkmod: Fix dependency count in kmod_module_parse_depline()

The variable n is intended to track the number of dependencies for mod.
However, it is only initialized and not incremented during dependency parsing.

Fix it.

Signed-off-by: Yuntao Wang <yuntao.wang@linux.dev>
Fixes: be728dd34718 ("libkmod: Simplify module dependency parsing")
Link: https://github.com/kmod-project/kmod/pull/348
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agoci: bump the all-actions group with 2 updates
dependabot[bot] [Thu, 1 May 2025 01:29:29 +0000 (01:29 +0000)] 
ci: bump the all-actions group with 2 updates

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

Updates `github/codeql-action` from 3.28.13 to 3.28.16
- [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/1b549b9259bda1cb5ddde3b41741a82a2d15a841...28deaeda66b76a05916b6923827895f2b14ab387)

Updates `codecov/codecov-action` from 5.4.0 to 5.4.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/0565863a31f2c772f9f0395002a31e3f06189574...ad3126e916f78f00edff4ed0317cf185271ccc2d)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.28.16
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-actions
- dependency-name: codecov/codecov-action
  dependency-version: 5.4.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Link: https://github.com/kmod-project/kmod/pull/342
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agoci: install curl in Ubuntu container
Emil Velikov [Sun, 11 May 2025 18:34:52 +0000 (19:34 +0100)] 
ci: install curl in Ubuntu container

With codecov v5, the script/action requires curl (and maybe more)
although the documentation wasn't updated. Furthermore, the missing
program will be reported in the logs, while the action will report
overall success :facepalm:

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/347
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agoshared: rework fd_lookup_path() helper
Emil Velikov [Wed, 7 May 2025 11:31:45 +0000 (12:31 +0100)] 
shared: rework fd_lookup_path() helper

Reduce the stack and heap memory usage of the helper by using a caller
provided buffer. This allows us to avoid copying the path, yet again,
within the caller.

Aside: readlink(3) returns -1 on all errors, it won't return the
prospective size if the output buffer is too small.

v2:
 - swap fd_lookup_path() path/pathlen argument order

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/345
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agoshared: remove unreachable snprintf error case
Emil Velikov [Wed, 7 May 2025 10:58:56 +0000 (11:58 +0100)] 
shared: remove unreachable snprintf error case

It is practically impossible for `/proc/self/fd/%d` to result in a
string of PATH_MAX size. Remove the unreachable error handling.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/345
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agoUse sizeof() over PATH_MAX for bounds handling
Emil Velikov [Sat, 5 Apr 2025 10:39:42 +0000 (11:39 +0100)] 
Use sizeof() over PATH_MAX for bounds handling

Bunch of our codebase uses sizeof() while the rest hard-coded length for
the destination buffer. Converge on the former since it makes for more
obvious and less error prone code.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/345
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agoUse sizeof() over PATH_MAX in snprintf() contexts
Emil Velikov [Sat, 5 Apr 2025 10:39:42 +0000 (11:39 +0100)] 
Use sizeof() over PATH_MAX in snprintf() contexts

Bunch of our codebase uses sizeof() while the rest hard-coded length for
the destination buffer. Converge on the former since it makes for more
obvious and less error prone code.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/345
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agoinsmod: Support --force-{vermagic,modversion} arguments
Rong Tao [Fri, 25 Apr 2025 07:47:28 +0000 (15:47 +0800)] 
insmod: Support --force-{vermagic,modversion} arguments

Supports --force-{vermagic,modversion} parameter like modprobe.

Link: https://github.com/kmod-project/kmod/pull/340
Signed-off-by: Rong Tao <rongtao@cestc.cn>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agotestsuite: fix dirty rootfs error message
Dawid Osuchowski [Sat, 26 Apr 2025 19:58:57 +0000 (21:58 +0200)] 
testsuite: fix dirty rootfs error message

Running a test binary directly on a dirty rootfs results in the
following error message:

        ERR: rootfs is dirty, please run
'meson compile testsuite/stamp-rootfs' before running this test

Running the command specified by the error message fails:

        $ meson compile testsuite/stamp-rootfs
        ERROR: Can't invoke target `testsuite/stamp-rootfs`:
target not found

Fix the error message to display the proper target.

Fixes: b85b2a0 ("testsuite: update "make rootfs" error message")
Signed-off-by: Dawid Osuchowski <linux@osuchow.ski>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2 months agomodprobe: Fix typo
Rong Tao [Fri, 25 Apr 2025 07:49:17 +0000 (15:49 +0800)] 
modprobe: Fix typo

Argument --force-modversions should be --force-modversion

Link: https://github.com/kmod-project/kmod/pull/339
Signed-off-by: Rong Tao <rongtao@cestc.cn>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
3 months agoci: bump github/codeql-action in the all-actions group
dependabot[bot] [Tue, 1 Apr 2025 01:57:28 +0000 (01:57 +0000)] 
ci: bump github/codeql-action in the all-actions group

Bumps the all-actions group with 1 update: [github/codeql-action](https://github.com/github/codeql-action).

Updates `github/codeql-action` from 3.28.10 to 3.28.13
- [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/b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d...1b549b9259bda1cb5ddde3b41741a82a2d15a841)

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

Signed-off-by: dependabot[bot] <support@github.com>
Link: https://github.com/kmod-project/kmod/pull/330
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
3 months agodepmod: Fix possible 0 return on error
Lucas De Marchi [Thu, 3 Apr 2025 04:17:27 +0000 (23:17 -0500)] 
depmod: Fix possible 0 return on error

errno may be long overwritten at this point and doesn't mean much on a
return from the cb(). Just replace with the same error we are output on
the log.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/337
3 months agotmpfile-util: Drop libgen.h
Lucas De Marchi [Thu, 3 Apr 2025 04:39:17 +0000 (23:39 -0500)] 
tmpfile-util: Drop libgen.h

We don't want the version of basename() that may leak memory - we want
the sane one. I remembered to add the missing.h while editing commit
aae48bc9f73a ("depmod: add tmpfile-util to generate temporary file") to
merge it, but completely forgot to remove the libgen.h. Fix it now.

Fixes: aae48bc9f73a ("depmod: add tmpfile-util to generate temporary file")
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/335
3 months agodepmod: add tmpfile-util to generate temporary file
Wang, Wenjie2 [Wed, 19 Mar 2025 01:54:08 +0000 (01:54 +0000)] 
depmod: add tmpfile-util to generate temporary file

* we use `mkstemp` to create the temporary file since it's a general
  function in linux system and O_TMPFILE is not supported on all linux
  system.
* add `struct tmpfile` to keep the `dirfd`, temp file `fd` and the
  filename.

Co-developed-by: Wenjie Wang <wenjie2.wang@intel.com>
Signed-off-by: Wenjie Wang <wenjie2.wang@intel.com>
Co-developed-by: Gongjun Song <gongjun.song@intel.com>
Signed-off-by: Gongjun Song <gongjun.song@intel.com>
Signed-off-by: Dan He <dan.h.he@intel.com>
Signed-off-by: Qingqing Li <qingqing.li@intel.com>
Signed-off-by: Yuchi Chen <yuchi.chen@intel.com>
Link: https://github.com/kmod-project/kmod/pull/305
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
3 months agoDrop leftover makefiles
Lucas De Marchi [Tue, 1 Apr 2025 17:06:36 +0000 (12:06 -0500)] 
Drop leftover makefiles

I don't think this was used before (at least I always build from the git
rootdir), and now that autotools is removed, they are wrong.

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/334
3 months agomodprobe: s|<MSEC>|MSEC|
Emil Velikov [Tue, 1 Apr 2025 13:26:38 +0000 (14:26 +0100)] 
modprobe: s|<MSEC>|MSEC|

Drop the brackets to stay consistent with quoting of other arguments -
see --config and friends further down.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/332
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
3 months agotestsuite/test-multi-softdep: style polish
Emil Velikov [Tue, 1 Apr 2025 15:32:03 +0000 (16:32 +0100)] 
testsuite/test-multi-softdep: style polish

Add a few trailing commas and reshuffle things so clang-format doesn't
get confused and we follow the existing style.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/333
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
3 months agotestsuite: remove #define pr_fmt
Emil Velikov [Tue, 1 Apr 2025 15:32:03 +0000 (16:32 +0100)] 
testsuite: remove #define pr_fmt

The kernel headers already provide a default which is sufficient for out
needs.

Inspired by a few new test modules which set it, although never call
pr_warn() or friends.

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