]> git.ipfire.org Git - thirdparty/kmod.git/log
thirdparty/kmod.git
5 hours agomeson: Add 'man' alias target master
Lucas De Marchi [Fri, 7 Aug 2026 04:56:02 +0000 (23:56 -0500)] 
meson: Add 'man' alias target

Allow to build all man pages without depending on the rest of the build.

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/455
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
5 hours agoci: Allow to generate docs for past release
Lucas De Marchi [Thu, 6 Aug 2026 14:51:01 +0000 (09:51 -0500)] 
ci: Allow to generate docs for past release

Add a workflow_dispatch that accepts the tag as input. This should allow
docs to be generated for a past release and populate the
https://kmod-project.github.io/ website.

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/455
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
5 hours agoci: Fix html docs build
Lucas De Marchi [Thu, 6 Aug 2026 14:34:09 +0000 (09:34 -0500)] 
ci: Fix html docs build

The html docs is not build by default. Also, there's no need to build
anything else: the custom target for docs can be executed directly.
Finally, move to the newly-introduced 'docs' alias.

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/455
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
5 hours agomeson: Add a 'docs' alias target
Lucas De Marchi [Thu, 6 Aug 2026 14:31:26 +0000 (09:31 -0500)] 
meson: Add a 'docs' alias target

libkmod-3-docs is too long and hard to remember. Add an alias.

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/455
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 hours ago.codespellignore: remove caf instance
Emil Velikov [Sun, 2 Aug 2026 12:44:37 +0000 (13:44 +0100)] 
.codespellignore: remove caf instance

The `caf` originates from the manual tar caf invocation, as part of the
(now defunct) autotools build.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/451
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 hours agovalgrind: add one more dlopen suppression
Emil Velikov [Sun, 2 Aug 2026 12:26:13 +0000 (13:26 +0100)] 
valgrind: add one more dlopen suppression

This gets Valgrind on my Arch box to be 100% "leak-free" ;-)

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/451
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 hours agomodinfo: rework parm string length validation
Emil Velikov [Sun, 2 Aug 2026 12:26:13 +0000 (13:26 +0100)] 
modinfo: rework parm string length validation

Currently, we if we fail to find a name, description or type in the
value token we emit an error and continue.

At the same time, if the name is longer than INT_MAX we error out.
Move the validation (overall strlen(value), which includes namelen)
further up the call stack and make it a non-fatal.

This allows us to garbage collect the no longer reachable error paths
around {add,process}_param().

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/451
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 hours agomodinfo: kill off struct param::{desc,type}len
Emil Velikov [Sun, 2 Aug 2026 12:26:13 +0000 (13:26 +0100)] 
modinfo: kill off struct param::{desc,type}len

The respective strings are guaranteed to be nil terminated, so drop the
strlen() and respective len(th) fields.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/451
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 hours agomodinfo: rework parm handling
Emil Velikov [Sun, 2 Aug 2026 12:26:13 +0000 (13:26 +0100)] 
modinfo: rework parm handling

Currently, we grow a list of parm entries and print each entry upon
being added. In addition, we have two separate code-paths for printing
depending if "--field parm" was provided on not.

Swap that for sufficiently sized, pre-allocated, buffers and unify the
print paths. Effectively fixing the broken `modinfo -0 modulename`
output.

v2:
 - find matching or empty entry in a single loop (add_param)
 - match up-to UINT_MAX parm/parmtype entries
 - drop unneeded INT_MAX checks for strlen(value)
 - don't return success if we fail to [cm]alloc

v3:
 - scope variable declaration
 - code dedup in parm/parmtype paths
 - use correct counter
 - avoid allocations on 0 parm(s)
 - (re)use strbuf

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/451
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 hours agoUse DECLARE_STRBUF where possible
Emil Velikov [Sun, 2 Aug 2026 12:26:13 +0000 (13:26 +0100)] 
Use DECLARE_STRBUF where possible

_cleanup_strbuf_ + strbuf_init() can be replaced by DECLARE_STRBUF.
Make all call-sites to use the respective macro.

The one place still calling strbuf_init() in strbuf_to_vector()
is "documenting" that strbuf is invalidated after its data is stolen,
so keep it as is for now.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/451
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 hours agoshared/strbuf: make strbuf_reserve_extra public
Emil Velikov [Sun, 2 Aug 2026 12:26:13 +0000 (13:26 +0100)] 
shared/strbuf: make strbuf_reserve_extra public

We'll need the function shortly, so make it public (within kmod).
In the process, re-introduce the test with some changes:
 - cosmetics - test function signature, new test macros, DECLARE_*
 - do not request an extra byte for \0
 - check both ::size and ::bytes

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/451
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 hours agoshared/strbuf: introduce and use ALIGN
Emil Velikov [Sun, 2 Aug 2026 12:26:13 +0000 (13:26 +0100)] 
shared/strbuf: introduce and use ALIGN

Introduce the simple macro and use it to (better) illustrate the strbuf
size calculation.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/451
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 hours agoshared/strbuf: remove always-true check in buf_realloc()
Emil Velikov [Sun, 2 Aug 2026 12:26:13 +0000 (13:26 +0100)] 
shared/strbuf: remove always-true check in buf_realloc()

The only caller of buf_realloc() already ensues that the size is 1 or
more so let's drop the if statement.

Cc: Tobias Stoeckmann <tobias@stoeckmann.org>
Fixes: 2b475981 ("shared: let strbuf_str never fail")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/451
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 hours agoshared/strbuf: avoid overflow due to \0 byte
Emil Velikov [Sun, 2 Aug 2026 12:26:13 +0000 (13:26 +0100)] 
shared/strbuf: avoid overflow due to \0 byte

Earlier commit reworked so we always allocate space for the \0 byte.
Although it did not (fully) consider that it can be the reason for an
overflow.

Cc: Tobias Stoeckmann <tobias@stoeckmann.org>
Fixes: 2b475981 ("shared: let strbuf_str never fail")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/451
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 hours agomodinfo: add a couple of print_{all,parm} booleans
Emil Velikov [Sun, 2 Aug 2026 12:26:13 +0000 (13:26 +0100)] 
modinfo: add a couple of print_{all,parm} booleans

Add a couple of booleans to arguably make the code a wee-bit cleaner
to follow. A follow-up commit will further reuse the latter (print_parm)
to avoid repeatedly calling streq().

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/451
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 hours agomodinfo: return early when --field is provided
Emil Velikov [Sun, 2 Aug 2026 12:26:13 +0000 (13:26 +0100)] 
modinfo: return early when --field is provided

No point in continuing if only a certain field is requested.

While in here, use a consistent code-pattern for the process.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/451
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 hours agomodinfo: flesh out and reuse print_line helper
Emil Velikov [Sun, 2 Aug 2026 12:26:13 +0000 (13:26 +0100)] 
modinfo: flesh out and reuse print_line helper

Thus using the correct format when `--null` is specified. In particular,
the both name + filename use the correct format, when --null (mode) is
requested.

v2:
 - call kmod_module_get_name() as needed

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/451
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 hours agomodinfo: introduce/use enum parm_info
Emil Velikov [Sun, 2 Aug 2026 12:26:13 +0000 (13:26 +0100)] 
modinfo: introduce/use enum parm_info

Store the `parm` vs `parmtype` instance as an enum, saving another
streq() shortly afterwards.

There's no practical benefit apart from making the code a tiny bit
clearer IMHO.

v2: Change enum names

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/451
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 hours agomodinfo: rename param::param{,len} to desc{,len}
Emil Velikov [Sun, 2 Aug 2026 12:26:13 +0000 (13:26 +0100)] 
modinfo: rename param::param{,len} to desc{,len}

The field provides end-user description what the parameter is used for.
Rename it accordingly.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/451
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 hours agomodinfo: add TODO about "name:" for builtins
Emil Velikov [Sun, 2 Aug 2026 12:26:13 +0000 (13:26 +0100)] 
modinfo: add TODO about "name:" for builtins

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/451
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 hours agomodinfo: skip parm entries without a name
Emil Velikov [Sun, 2 Aug 2026 12:26:13 +0000 (13:26 +0100)] 
modinfo: skip parm entries without a name

Specially crafted/corrupt modules may have a parm/parmtype entry which
lacks the "name:" prefix. Throw a warning and skip such entries.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/451
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 hours agomodinfo: fixup type-only parm print format
Emil Velikov [Sun, 2 Aug 2026 12:26:13 +0000 (13:26 +0100)] 
modinfo: fixup type-only parm print format

The generic (full) expression is:
 - "$name:$parm ($type)"

Although currently, if no $parm is available and --field isn't used we
instead print:
 - "$name:$type"

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/451
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 hours agoCONTRIBUTING: mention ninja clang-format
Lucas De Marchi [Sat, 8 Aug 2026 05:17:25 +0000 (00:17 -0500)] 
CONTRIBUTING: mention ninja clang-format

No additional tool needed, should be readily available.

Link: https://github.com/kmod-project/kmod/pull/312
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 hours agolibkmod: Fix missing module normalization from kernel cmdline
Lucas De Marchi [Sat, 8 Aug 2026 04:18:11 +0000 (23:18 -0500)] 
libkmod: Fix missing module normalization from kernel cmdline

Normalize it before adding the blacklist. Without normalizing it we
have, with just the test addition:

$ ./build/testsuite/test-modprobe modprobe_param_kcmdline9
TESTSUITE: running modprobe_param_kcmdline9, in forked context
TESTSUITE: ERR: Outputs do not match on STDOUT:
TESTSUITE: ERR: correct:
...
blacklist foo_bar
...
TESTSUITE: ERR: wrong:
blacklist foo-bar
TESTSUITE: ERR: FAILED: exit ok but outputs do not match: modprobe_param_kcmdline9

Link: https://github.com/kmod-project/kmod/pull/312
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 hours agolibkmod: unref list before returning with error
Jakub Ślepecki [Fri, 20 Jun 2025 15:59:07 +0000 (17:59 +0200)] 
libkmod: unref list before returning with error

In case of error path this might have led to, for example:

    ==86629==ERROR: LeakSanitizer: detected memory leaks

    Direct leak of 24 byte(s) in 1 object(s) allocated from:
        #0 0x7fa904b20e15  (/usr/lib/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../lib/libasan.so+0x120e15) (BuildId: 9dccfc42ea2d9790ff7cf76cc8a3210650e604e0)
        #1 0x55d74820fc8a  ($kmod/build/kmod+0xefc8a) (BuildId: e7c136c95271cf020398e33fd5577d82adc7a47c)
        #2 0x55d7482173a6  ($kmod/build/kmod+0xf73a6) (BuildId: e7c136c95271cf020398e33fd5577d82adc7a47c)
        #3 0x55d74821a617  ($kmod/build/kmod+0xfa617) (BuildId: e7c136c95271cf020398e33fd5577d82adc7a47c)
        #4 0x55d7481e2d80  ($kmod/build/kmod+0xc2d80) (BuildId: e7c136c95271cf020398e33fd5577d82adc7a47c)
        #5 0x55d7481e314f  ($kmod/build/kmod+0xc314f) (BuildId: e7c136c95271cf020398e33fd5577d82adc7a47c)
        #6 0x55d7481e658c  ($kmod/build/kmod+0xc658c) (BuildId: e7c136c95271cf020398e33fd5577d82adc7a47c)
        #7 0x7fa9038376b4  (/usr/lib/libc.so.6+0x276b4) (BuildId: 468e3585c794491a48ea75fceb9e4d6b1464fc35)
        #8 0x7fa903837768  (/usr/lib/libc.so.6+0x27768) (BuildId: 468e3585c794491a48ea75fceb9e4d6b1464fc35)
        #9 0x55d7481c3334  ($kmod/build/kmod+0xa3334) (BuildId: e7c136c95271cf020398e33fd5577d82adc7a47c)

    Indirect leak of 4120 byte(s) in 1 object(s) allocated from:
        #0 0x7fa904b2073d  (/usr/lib/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../lib/libasan.so+0x12073d) (BuildId: 9dccfc42ea2d9790ff7cf76cc8a3210650e604e0)
        #1 0x55d7481eb8eb  ($kmod/build/kmod+0xcb8eb) (BuildId: e7c136c95271cf020398e33fd5577d82adc7a47c)
        #2 0x55d7481f6fee  ($kmod/build/kmod+0xd6fee) (BuildId: e7c136c95271cf020398e33fd5577d82adc7a47c)
        #3 0x55d7481e52c4  ($kmod/build/kmod+0xc52c4) (BuildId: e7c136c95271cf020398e33fd5577d82adc7a47c)
        #4 0x7fa9038376b4  (/usr/lib/libc.so.6+0x276b4) (BuildId: 468e3585c794491a48ea75fceb9e4d6b1464fc35)
        #5 0x7fa903837768  (/usr/lib/libc.so.6+0x27768) (BuildId: 468e3585c794491a48ea75fceb9e4d6b1464fc35)
        #6 0x55d7481c3334  ($kmod/build/kmod+0xa3334) (BuildId: e7c136c95271cf020398e33fd5577d82adc7a47c)

    [...]

    SUMMARY: AddressSanitizer: 5701 byte(s) leaked in 27 allocation(s).

Co-authored-by: Dawid Osuchowski <dawid.osuchowski@linux.intel.com>
Signed-off-by: Dawid Osuchowski <dawid.osuchowski@linux.intel.com>
Signed-off-by: Jakub Ślepecki <jakub.slepecki@intel.com>
Link: https://github.com/kmod-project/kmod/pull/312
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 hours agotestsuite: test-modprobe: modprobe with blacklist
Jakub Ślepecki [Fri, 20 Jun 2025 15:59:01 +0000 (17:59 +0200)] 
testsuite: test-modprobe: modprobe with blacklist

Until now blacklist command was only covered by test-blacklist at
libkmod interface level. A regular user will usually interact with it
via modprobe(8). This commit adds tests for modprobe, alias filtering,
and -b option. It is also intended as an example of -b usage.

Co-authored-by: Dawid Osuchowski <dawid.osuchowski@linux.intel.com>
Signed-off-by: Dawid Osuchowski <dawid.osuchowski@linux.intel.com>
Signed-off-by: Jakub Ślepecki <jakub.slepecki@intel.com>
Link: https://github.com/kmod-project/kmod/pull/312
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 hours agoFix some trivial coding style issues
Lucas De Marchi [Sat, 8 Aug 2026 05:05:07 +0000 (00:05 -0500)] 
Fix some trivial coding style issues

Make clang-format happy.

Link: https://github.com/kmod-project/kmod/pull/312
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
4 days agoci: bump the all-actions group across 1 directory with 5 updates
dependabot[bot] [Sat, 1 Aug 2026 01:25:36 +0000 (01:25 +0000)] 
ci: bump the all-actions group across 1 directory with 5 updates

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

| Package | From | To |
| --- | --- | --- |
| [actions/checkout](https://github.com/actions/checkout) | `6.0.2` | `7.0.1` |
| [github/codeql-action/init](https://github.com/github/codeql-action) | `4.35.2` | `4.37.3` |
| [github/codeql-action/analyze](https://github.com/github/codeql-action) | `4.35.2` | `4.37.3` |
| [github/codeql-action/upload-sarif](https://github.com/github/codeql-action) | `4.35.2` | `4.37.3` |
| [codecov/codecov-action](https://github.com/codecov/codecov-action) | `6.0.0` | `7.0.0` |

Updates `actions/checkout` from 6.0.2 to 7.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/de0fac2e4500dabe0009e67214ff5f5447ce83dd...3d3c42e5aac5ba805825da76410c181273ba90b1)

Updates `github/codeql-action/init` from 4.35.2 to 4.37.3
- [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/95e58e9a2cdfd71adc6e0353d5c52f41a045d225...e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81)

Updates `github/codeql-action/analyze` from 4.35.2 to 4.37.3
- [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/95e58e9a2cdfd71adc6e0353d5c52f41a045d225...e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81)

Updates `github/codeql-action/upload-sarif` from 4.35.2 to 4.37.3
- [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/95e58e9a2cdfd71adc6e0353d5c52f41a045d225...e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81)

Updates `codecov/codecov-action` from 6.0.0 to 7.0.0
- [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/57e3a136b779b570ffcdbf80b3bdc90e7fab3de2...fb8b3582c8e4def4969c97caa2f19720cb33a72f)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 7.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: all-actions
- dependency-name: codecov/codecov-action
  dependency-version: 7.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: all-actions
- dependency-name: github/codeql-action/analyze
  dependency-version: 4.36.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-actions
- dependency-name: github/codeql-action/init
  dependency-version: 4.36.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-actions
- dependency-name: github/codeql-action/upload-sarif
  dependency-version: 4.36.2
  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/447
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
4 days agoInclude fcntl.h where needed
Emil Velikov [Sat, 1 Aug 2026 19:57:10 +0000 (20:57 +0100)] 
Include fcntl.h where needed

I was toying around with a home-made version of include-what-you-use,
which showed that we're missing the include in a number of places.

At the moment it is indirectly resolved via libkmod.h, which pulls said
header for O_TRUNC and O_NONBLOCK. It's unlikely that we'll drop the
include from the public header, although that doesn't mean that aiming
for self-contained sources is a bad idea.

For context: I am looking to remove the libkmod static link to
init-module.so and part of that meant building libkmod-elf.c without
the rest of kmod.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/452
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
4 days agolibkmod: rename/reuse xz_error()
Emil Velikov [Sun, 2 Aug 2026 13:28:02 +0000 (14:28 +0100)] 
libkmod: rename/reuse xz_error()

Swap "belch" for a more common name and use the function in all possible
error paths.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/452
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
4 days agolibkmod: s/gzip/zlib/ for consistency sake
Emil Velikov [Sun, 2 Aug 2026 13:23:05 +0000 (14:23 +0100)] 
libkmod: s/gzip/zlib/ for consistency sake

The other errors use zlib (the library) instead of gzip. Convert the
final instance.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/452
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
4 days agolibkmod: remove duplicate _func_ in error messages
Emil Velikov [Sun, 2 Aug 2026 13:19:58 +0000 (14:19 +0100)] 
libkmod: remove duplicate _func_ in error messages

Our logging macros already provide __func__ throughout. Drop the few
instances which manually add it yet again.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/452
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
5 days agoManually handle unrecognised getopt arguments
Emil Velikov [Sun, 2 Aug 2026 14:19:30 +0000 (15:19 +0100)] 
Manually handle unrecognised getopt arguments

Was meaning to add a negative test or two to modinfo - where a invalid
option is passed into the program - only to notice that the default will
print the path, alongside the program name.

While fixing that, I've decided to pimp-up the reporting to also show
the help screen.

Eg. from this:

/usr/bin/insmod: unrecognized option '--versoin'

... to this

insmod: ERROR: unrecognised option '--versoin'

Usage:
insmod [options] filename [module options]
Options:
-f, --force              DANGEROUS: forces a module load, may cause
                         data corruption and crash your machine.
                         implies --force-modversion and
                         --force-vermagic
    --force-modversion   Ignore module's version
    --force-vermagic     Ignore module's version magic
-s, --syslog             print to syslog, not stderr
-v, --verbose            enables more messages
-V, --version            show version
-h, --help               show this help

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/453
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
5 days agoConsistently handle getopt
Emil Velikov [Sat, 19 Oct 2024 17:11:17 +0000 (18:11 +0100)] 
Consistently handle getopt

Pull the unistd.h for optind and adjust the loop to follow the
in-documentation example.

In addition, we don't need the unused idx.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/453
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
5 days agoUse consistent struct option declaration
Emil Velikov [Sun, 2 Aug 2026 13:54:11 +0000 (14:54 +0100)] 
Use consistent struct option declaration

The struct option::flag is of type "int *", so we should be using NULL
instead of 0. In addition, the sentinel entry can be left completely
empty.

With those in place, we can drop most of the clang-format notations.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/453
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
5 days agoci: Fix MAKEFLAGS handling
Lucas De Marchi [Wed, 5 Aug 2026 14:07:11 +0000 (09:07 -0500)] 
ci: Fix MAKEFLAGS handling

Fix commit 47999f7f4fcd ("ci: Workaround alpine CI build"). When tested
it created an inavlid yml and the overall of CI status showed as "passed",
giving the wrong impression that it had fixed the breakage. On the
contrary, it only became even more borken. Try to fix it for good.

Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
5 days agoci: Workaround alpine CI build
Lucas De Marchi [Mon, 3 Aug 2026 20:52:21 +0000 (15:52 -0500)] 
ci: Workaround alpine CI build

Alpine build is failing in CI apparently since the move to 7.1.x:

  error: objtool [signal.c:118]: init_signal_handler: sigaltstack failed: Out of memory
  make[4]: *** [/usr/src/linux-headers-7.1.5-0-stable/scripts/Makefile.build:289: mod-foo-a.o] Error 255
  make[4]: *** Deleting file 'mod-foo-a.o'

Workaround by passing -j1 when building the test modules.

Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/454
5 days agoci: Add pahole to alpine
Lucas De Marchi [Mon, 3 Aug 2026 20:29:31 +0000 (15:29 -0500)] 
ci: Add pahole to alpine

Drop warning from CI:

  make[2]: Entering directory '/__w/kmod/kmod/builddir-gcc-64/testsuite/module-playground'
  warning: pahole version differs from the one used to build the kernel
    The kernel was built with: 130
    You are using:             0

Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
Link: https://github.com/kmod-project/kmod/pull/454
13 days agoCOPYING: drop double-space the Copyright example
Emil Velikov [Sat, 18 Jul 2026 17:42:20 +0000 (18:42 +0100)] 
COPYING: drop double-space the Copyright example

I am assuming that the COPYING boilerplate is the source for all the
varying double-space instances we have (had) in-tree.

Update those, so we can avoid them in the future.

As always, the typical IANAL disclaimer applies. To the best of my
knowledge and understanding the two forms are identical. With the
original being _slightly_ annoying especially if your editor
high-lights the double-space.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agoRemove double-space in Copyright boilerplate
Emil Velikov [Sat, 18 Jul 2026 17:35:02 +0000 (18:35 +0100)] 
Remove double-space in Copyright boilerplate

The amount of double space (and variation) in the Copyright statements
is... Interesting.

As always, the typical IANAL disclaimer applies. To the best of my
knowledge and understanding the two forms are identical. With the
original being _slightly_ annoying especially if your editor
high-lights the double-space.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agotestsuite: add respective Copyright year
Emil Velikov [Sat, 18 Jul 2026 17:28:03 +0000 (18:28 +0100)] 
testsuite: add respective Copyright year

The Copyright header was pulled props to the weakdep test, which was
written/merged in 2024. Add the respective year, so the copyright
statement is valid.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agotestsuite: rename test-list -> test-libkmod-list
Emil Velikov [Sat, 18 Jul 2026 17:10:12 +0000 (18:10 +0100)] 
testsuite: rename test-list -> test-libkmod-list

Unlike the other libkmod tests, this one explicitly covers internal-only
API. As such keep it separate, to avoid pulling (again) the internal
headers and potentially leaking implementation details where they should
not be found.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agotestsuite: fold test-weakdep into test-libkmod
Emil Velikov [Sat, 18 Jul 2026 14:06:14 +0000 (15:06 +0100)] 
testsuite: fold test-weakdep into test-libkmod

Arguably improves things by providing some grouping and clarity on the
origin, structure and coverage of the tests.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agotestsuite: fold test-multi-softdep into test-libkmod
Emil Velikov [Sat, 18 Jul 2026 14:06:14 +0000 (15:06 +0100)] 
testsuite: fold test-multi-softdep into test-libkmod

Arguably improves things by providing some grouping and clarity on the
origin, structure and coverage of the tests.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agotestsuite: fold test-dependencies into test-libkmod
Emil Velikov [Sat, 18 Jul 2026 14:06:14 +0000 (15:06 +0100)] 
testsuite: fold test-dependencies into test-libkmod

Arguably improves things by providing some grouping and clarity on the
origin, structure and coverage of the tests.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agotestsuite: fold test-loaded into test-libkmod
Emil Velikov [Sat, 18 Jul 2026 14:06:14 +0000 (15:06 +0100)] 
testsuite: fold test-loaded into test-libkmod

Arguably improves things by providing some grouping and clarity on the
origin, structure and coverage of the tests.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agotestsuite: fold test-blacklist into test-libkmod
Emil Velikov [Sat, 18 Jul 2026 14:06:14 +0000 (15:06 +0100)] 
testsuite: fold test-blacklist into test-libkmod

Arguably improves things by providing some grouping and clarity on the
origin, structure and coverage of the tests.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agotestsuite: fold test-initstate into test-libkmod
Emil Velikov [Sat, 18 Jul 2026 14:06:14 +0000 (15:06 +0100)] 
testsuite: fold test-initstate into test-libkmod

Arguably improves things by providing some grouping and clarity on the
origin, structure and coverage of the tests.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agotestsuite: fold test-new-module into test-libkmod
Emil Velikov [Sat, 18 Jul 2026 14:06:14 +0000 (15:06 +0100)] 
testsuite: fold test-new-module into test-libkmod

Arguably improves things by providing some grouping and clarity on the
origin, structure and coverage of the tests.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agotestsuite: rename test-{init,remove} -> test-libkmod
Emil Velikov [Sat, 18 Jul 2026 14:01:32 +0000 (15:01 +0100)] 
testsuite: rename test-{init,remove} -> test-libkmod

We're starting to consolidate/fold the dozen+ tests into a few top-level
ones. This is the first step, renaming the first shared (utility) into
the final unified location.

We're moving both test-init and test-remove at the same time, while
renaming the latter, to workaround a meson complaint as below:

  rootfs ... is dirty, please run 'meson compile testsuite/create-...

Suspecting some form of bug in the test and/or setup, but unwrapping
that's for another day.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agotestsuite: move modprobe test into test-modprobe.c
Emil Velikov [Sat, 18 Jul 2026 13:14:50 +0000 (14:14 +0100)] 
testsuite: move modprobe test into test-modprobe.c

... alongside all the other modprobe tests.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agotestsuite: fold test-util into test-shared
Emil Velikov [Sat, 18 Jul 2026 14:06:14 +0000 (15:06 +0100)] 
testsuite: fold test-util into test-shared

Arguably improves things by providing some grouping and clarity on the
origin, structure and coverage of the tests.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agotestsuite: fold test-strbuf into test-shared
Emil Velikov [Sat, 18 Jul 2026 14:06:14 +0000 (15:06 +0100)] 
testsuite: fold test-strbuf into test-shared

Arguably improves things by providing some grouping and clarity on the
origin, structure and coverage of the tests.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agotestsuite: fold test-hash into test-shared
Emil Velikov [Sat, 18 Jul 2026 14:06:14 +0000 (15:06 +0100)] 
testsuite: fold test-hash into test-shared

Arguably improves things by providing some grouping and clarity on the
origin, structure and coverage of the tests.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agotestsuite: rename test-array -> test-shared
Emil Velikov [Sat, 18 Jul 2026 14:01:32 +0000 (15:01 +0100)] 
testsuite: rename test-array -> test-shared

We're starting to consolidate/fold the dozen+ tests into a few top-level
ones. This is the first step, renaming the first shared (utility) into
the final unified location.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agoshared: rename tmpfile-util -> tmpfile
Emil Velikov [Sat, 18 Jul 2026 09:19:12 +0000 (10:19 +0100)] 
shared: rename tmpfile-util -> tmpfile

None of the exiting files have similar suffixes, so let's drop the odd
one out.

While in there, properly sort the meson source listing.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agotestsuite: remove UNIQ(testname)
Emil Velikov [Sat, 18 Jul 2026 09:11:13 +0000 (10:11 +0100)] 
testsuite: remove UNIQ(testname)

Stop making the test name variable (section entry) unique. This is no
longer needed, plus we'll reshuffle some of the remaining names shortly.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agotestsuite: flip testsuite iteration order
Emil Velikov [Sat, 18 Jul 2026 12:59:38 +0000 (13:59 +0100)] 
testsuite: flip testsuite iteration order

The way the tests are added to the section is implementation specific.
Altohough in practise both gcc and clang to so in revert order. Thus if
we have tests defined as:

  DEFINE_TEST(first, ...);
  DEFINE_TEST(second, ...);
  ...
  DEFINE_TEST(last, ...);

A simple list/walk will be:

  last,
  ...
  second,
  first,

Reverse the order, so the output of `--list` and the execution is a
little more human friendly.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agotestsuite: tweak __{start,stop}_kmod_tests declaration
Emil Velikov [Sat, 18 Jul 2026 12:53:50 +0000 (13:53 +0100)] 
testsuite: tweak __{start,stop}_kmod_tests declaration

Const annotate the struct (we don't/cannot modify them) and drop the no
longer needed hidden attribute.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agotestsuite: add FIXME note about libkmod-internal.h include
Emil Velikov [Sat, 18 Jul 2026 15:23:18 +0000 (16:23 +0100)] 
testsuite: add FIXME note about libkmod-internal.h include

We really do not want to have dependency on an internal header(s), since
it opens the possibility of leaking implementation details into what
should be API level tests.

Although, it could be that we should remove kmod_list from the public
API all together... Something for another day either way.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agotestsuite: remove no longer needed undef hacks
Emil Velikov [Sat, 18 Jul 2026 15:21:58 +0000 (16:21 +0100)] 
testsuite: remove no longer needed undef hacks

As of last commit there are no conflicting ERR macros.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agotestsuite: add TS_ prefix to logging macros
Emil Velikov [Sat, 18 Jul 2026 14:54:05 +0000 (15:54 +0100)] 
testsuite: add TS_ prefix to logging macros

The tests have their own namespace (mostly at least), move the logging
macros to it accordingly. Thus we can remove the undef hacks that we
have in-tree.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agotestsuite: convert a should-be-unreachable LOG to an ERR
Emil Velikov [Sat, 18 Jul 2026 14:25:32 +0000 (15:25 +0100)] 
testsuite: convert a should-be-unreachable LOG to an ERR

Of the two call-sites to remove_directory() we have:
 - we explicitly stat/S_ISDIR check prior, and
 - the folder must exist, or out init_module.c implementation is broken

Thus is seems very unlikely to trigger the LOG and in practice, it
indicates a bug/race condition. Convert it to an ERR and return -1 to
indicate that.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
13 days agotestsuite: remove overly verbose logging
Emil Velikov [Sat, 18 Jul 2026 14:20:56 +0000 (15:20 +0100)] 
testsuite: remove overly verbose logging

The delete_module.c (LD_PRELOAD module) prints the result of the
TC_DELETE_MODULE_RETCODES parsing. At the same time the init_module.c
(and it's variant) don't bother.

Glancing throughout, no other test uses LOG so let's drop the logging
allowing us to garbage collect (hide really) the potentially conflicting
macros.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/450
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
3 weeks agotestsuite: s/return EXIT_SUCCESS/return 0/
Emil Velikov [Fri, 3 Jul 2026 12:05:03 +0000 (13:05 +0100)] 
testsuite: s/return EXIT_SUCCESS/return 0/

With all the EXIT_FAILURE instances done from the tests (only ones in
tools and the test runner remain), lets drop the EXIT_SUCCESS ones.

Functionally identical and arguably slightly neater.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/375
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
3 weeks agotestsuite: convert all tests to TS_ASSERT()
Emil Velikov [Fri, 3 Jul 2026 11:45:56 +0000 (12:45 +0100)] 
testsuite: convert all tests to TS_ASSERT()

Currently we have some inconsistencies across the tests:
 - using TS_ASSERT vs not
 - (non TS_ASSERT tests) leaking on error vs not

In practical terms, we are not too worried about the leaks, since the
test failure comes first. As such, convert all the tests to TS_ASSERT().

This means we loose the useful error messages in a few instances, which
could be re-introduced at a later point alongside a TS_ASSERT_MSG()
macro.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/375
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
3 weeks agotestsuite: replace assert_return with TS_ASSERT
Emil Velikov [Fri, 3 Jul 2026 10:35:53 +0000 (11:35 +0100)] 
testsuite: replace assert_return with TS_ASSERT

Mechanical change, done with:

sed -i  "s/assert_return/TS_ASSERT/;s/, EXIT_FAILURE//" testsuite/*.c

In addition, manually fixup the two multiline instances (test-strbuf.c
and test-util.c) and remove the no longer used macro.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/375
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
3 weeks agotestsuite: introduce TS_ASSERT reimplementing assert_return
Emil Velikov [Fri, 3 Jul 2026 10:20:42 +0000 (11:20 +0100)] 
testsuite: introduce TS_ASSERT reimplementing assert_return

The existing macro has a few shortcomings:
 - lowercase, non-prefixed so it can be confused with assert(3), which
   has varying behaviour depending on -DNDEBUG
 - the return value is constant across the project

Introduce TS_ASSERT which is modelled after KUNIT_ASSERT, addressing the
above and tweaking the output format.

Existing instances of assert_return will be updated with a follow-up
commit.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/375
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
3 weeks agotestsuite: don't use assert_return() for empty testsuite
Emil Velikov [Fri, 3 Jul 2026 10:50:04 +0000 (11:50 +0100)] 
testsuite: don't use assert_return() for empty testsuite

With follow-up commit we'll rework/remove the macro, where the new
version does not allow for providing the return value.

Swap it for a manual ERR, printing a more useful error message.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/375
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
5 weeks agoci: specify/run only the gcov pluin
Emil Velikov [Fri, 3 Jul 2026 21:46:17 +0000 (22:46 +0100)] 
ci: specify/run only the gcov pluin

The default has changed with codecov v5, where all existing plugins are
attempted. In practise we only need gcov, which seems to work file.

Specify it, saving us the following warning:

  coverage.py is not installed or can't be found.

Initially I tried adding it to the Ubuntu image, only to notice they
lack the looked for `coverage.py` executable and instead have
`python{version.minor}-coverage.py`.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/448
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
5 weeks agoci: use the correct argument for codecov
Emil Velikov [Fri, 3 Jul 2026 21:21:38 +0000 (22:21 +0100)] 
ci: use the correct argument for codecov

With codecov v5, their release note states (et al):

  The following arguments have been changed
    - `file` (this has been deprecated in favor of `files`)

Where they actually meant _removed_... Oopsie :-)

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/448
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
5 weeks agoci: add ubuntu-26.04, update runners
Emil Velikov [Fri, 3 Jul 2026 20:43:11 +0000 (21:43 +0100)] 
ci: add ubuntu-26.04, update runners

Ubuntu 26.04 is the first version to include mbedtls v3. Add it to the
build and update the runners to it.

Getting us a step closer to having a) formal code coverage for that path
and b) knowing what fixes we'll need once the runner is out of
"preview".

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/448
Signed-off-by: Lucas De Marchi <ldemarchi@kernel.org>
7 weeks agoci: enable mbedtls by default for most instances
Emil Velikov [Sun, 31 May 2026 20:07:03 +0000 (21:07 +0100)] 
ci: enable mbedtls by default for most instances

As the mbedtls introduction commit says, mbedtls v3 is not available in
Debian 12 and Ubuntu 22.04/24.04.

Although to ensure we have sufficient build coverage, let's enable it
everywhere else. While also adding a permutation where it's the only
crypto implementation built-in.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/426
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 weeks agombedlts: add as alternative to openssl
Emil Velikov [Sun, 15 Feb 2026 21:11:58 +0000 (21:11 +0000)] 
mbedlts: add as alternative to openssl

In a recent conversation improving the depmod runtime, we noticed that
kmod_module_signature_info() normally takes 20-25% of the total runtime
for uncompressed modules.

The related attempts at using threads, also indicated that OpenSSL may
not be thread-safe... At least, not the way we use it.

Enter Mbed TLS (formerly known as polarssl), self described as:

Mbed TLS is a C library that implements X.509 certificate manipulation ...
... Its small code footprint makes it suitable for embedded systems. ...

There are 3 major/LTS versions in the wild,
 - v2 released in 2015 - Debian 12- and Ubuntu 24.04-
 - v3 released in 2021 - Debian 13+, Ubuntu 25.04+ and everywhere*
 - v4 released in 2025 - close to non-existing adoption

In practical terms, using MbedTLS has proven to be a much shorter and
simpler implementation. Effectively eliminating the time spent in
kmod_module_signature_info() to practically zero. With the overall
execution time dropping respectively - 0.43s -> 0.35s on my machine.

From instructions/memory statistics POV, we have (per module):
 - ~50k fewer instructions
 - ~55 fewer memory allocations
 - ~2KB less memory is allocated

Also, Helgrind seems quite happy.

Availability aside, there are a few IMHO minor downsides:
 - MD4 support was removed with v3
 - SM3 support is not available - neither in v3 nor v4
 - No algo to string API

I wasn't able to find any distribution/builds that use MD4 or SM3 so
this aspect shouldn't be too critical.

Whereas for the algo-to-string API - it's a trivial mapping, that we can
(should?) copy from the kernel alongside the enum itself... But that's
an exercise for another day - alongside fixing the no openssl/mbedtls
code path.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/426
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 weeks agolibkmod: move openssl-related functions to separate file
Emil Velikov [Mon, 1 Jun 2026 14:45:57 +0000 (15:45 +0100)] 
libkmod: move openssl-related functions to separate file

Move openssl-related function to a separate file so it's easier to
isolate the dependency on each crypto library.

This will allow multiple implementations to co-exist in the same build.

As a nice side effect we fallback to the "dummy" implementation in the
(very likely) case that the openssl one fails.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/426
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 weeks agomeson: use arrays to manage module compressions/signatures
Emil Velikov [Mon, 1 Jun 2026 14:45:40 +0000 (15:45 +0100)] 
meson: use arrays to manage module compressions/signatures

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/426
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
7 weeks agolibkmod: Add build-id item to kmod_module_get_info()
Lucas De Marchi [Wed, 25 Mar 2026 05:28:46 +0000 (00:28 -0500)] 
libkmod: Add build-id item to kmod_module_get_info()

If available, add the build-id to the info list returned by
kmod_module_get_info(). This allows us to compare the build-id of a
loaded module versus the build-id of the file. It's rather cumbersome
command, but it works:

$ ./build/modinfo -F build-id hid
AE:7A:2E:37:E0:2B:31:D5:72:7C:87:87:15:8C:05:FA:77:7A:4F:57
$ xxd -p -u -s16  /sys/module/hid/notes/.note.gnu.build-id  | sed 's/../&:/g;s/:$//'
AE:7A:2E:37:E0:2B:31:D5:72:7C:87:87:15:8C:05:FA:77:7A:4F:57

An option to modinfo to really to just dump the raw value can be added
in future.

Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/432
7 weeks agolibkmod: Add helper to read .note.gnu.build-id section
Lucas De Marchi [Wed, 25 Mar 2026 04:34:28 +0000 (23:34 -0500)] 
libkmod: Add helper to read .note.gnu.build-id section

Read the .note.gnu.build-id section so it can be displayed by modinfo in
a future change. For now this is only added to pretty-print the id, but
later can be refactored to easily compare with the section dump from
/sys/module/<module-name>/.note.gnu.build-id

The section in the elf is potentially available since kernel 4.10 (if
toolchain supports it) and became unconditional since commit
89ff7131f78a ("kbuild: add --hash-style= and --build-id unconditionally")
since minimum toolchain versions got raised.

Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/432
7 weeks agolibkmod: Add elf_get_u32() helper
Lucas De Marchi [Thu, 23 Apr 2026 19:43:10 +0000 (14:43 -0500)] 
libkmod: Add elf_get_u32() helper

Shortcut to the size.

Keep this wrapper inline even after the previous de-inlining change:
it is a tiny typed helper around elf_get_uint() that avoids repeating
the uint32_t size at call sites, while the larger helpers can still be
left to the compiler.

Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/432
7 weeks agolibkmod: Drop too much inlining
Lucas De Marchi [Wed, 25 Mar 2026 04:21:57 +0000 (23:21 -0500)] 
libkmod: Drop too much inlining

Let the compiler decide depending on the optimization level.

Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/432
3 months agoci: bump the all-actions group with 3 updates
dependabot[bot] [Fri, 1 May 2026 01:41:12 +0000 (01:41 +0000)] 
ci: bump the all-actions group with 3 updates

Bumps the all-actions group with 3 updates: [github/codeql-action](https://github.com/github/codeql-action), [advanced-security/filter-sarif](https://github.com/advanced-security/filter-sarif) and [codecov/codecov-action](https://github.com/codecov/codecov-action).

Updates `github/codeql-action` from 4.32.0 to 4.35.2
- [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/b20883b0cd1f46c72ae0ba6d1090936928f9fa30...95e58e9a2cdfd71adc6e0353d5c52f41a045d225)

Updates `advanced-security/filter-sarif` from 1.0.1 to 1.1
- [Release notes](https://github.com/advanced-security/filter-sarif/releases)
- [Commits](https://github.com/advanced-security/filter-sarif/compare/f3b8118a9349d88f7b1c0c488476411145b6270d...2da736ff05ef065cb2894ac6892e47b5eac2c3c0)

Updates `codecov/codecov-action` from 5.5.2 to 6.0.0
- [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/671740ac38dd9b0130fbe1cec585b89eea48d3de...57e3a136b779b570ffcdbf80b3bdc90e7fab3de2)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.35.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-actions
- dependency-name: advanced-security/filter-sarif
  dependency-version: '1.1'
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-actions
- dependency-name: codecov/codecov-action
  dependency-version: 6.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: all-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Link: https://github.com/kmod-project/kmod/pull/435
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
3 months agoAdd and install valgrind suppression file
Emil Velikov [Sun, 8 Feb 2026 16:04:38 +0000 (16:04 +0000)] 
Add and install valgrind suppression file

We're leaking some dlopen handles, by design. It is cleaned up when the
process is closed and there is no reason to be concerned/alarmed.

To indicate that, let's ship a valgrind suppression file.

Admittedly these are not 100% enough since depending on the c runtime
and/or version it can leak some global state, which gets caught.

The newer the glibc version, the more likely it is to exbibit such
behaviour.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/420
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
3 months agomeson: Make dlopen=all the default
Lucas De Marchi [Fri, 24 Apr 2026 14:55:51 +0000 (09:55 -0500)] 
meson: Make dlopen=all the default

As of earlier commit, all dependencies can be dlopen'd on demand. Do
that for all optional libraries by default, but still allow it to be
overridden during build.

Example numbers/benefits taken from `modprobe --show-depends nouveau`:

 - fewer instr - 50% reduction, 1.2M -> 0.5M
 - less memory use - Rss by ~33%, 3M -> 2M
 - reduced attack surface

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/420
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
3 months agolibkmod: Add ELF note for openssl library
Emil Velikov [Sun, 8 Feb 2026 12:21:23 +0000 (12:21 +0000)] 
libkmod: Add ELF note for openssl library

Follow the new spec for ELF notes as detailed in
https://systemd.io/ELF_PACKAGE_METADATA/.

We can copy mostly verbatim the macros from systemd codebase.

Example output:

$ meson setup --native-file build-dev.ini -Ddlopen=openssl build
...
    dlopen           : openssl

    features         : +ZSTD +XZ +ZLIB +OPENSSL

$ dlopen-notes.py build/libkmod.so.2
# build/libkmod.so.2
[
  {
    "feature": "openssl",
    "description": "Support for reading module signatures",
    "priority": "suggested",
    "soname": [
      "libcrypto.so.3"
    ]
  }
]

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/420
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
3 months agolibkmod: Allow to load libcrypto.so on demand
Emil Velikov [Sun, 8 Feb 2026 12:13:42 +0000 (12:13 +0000)] 
libkmod: Allow to load libcrypto.so on demand

Use dlfcn helpers to load libcrypto once it's needed.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/420
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
3 months agomeson: bump minimal openssl/libcrypto to 3.0.0
Emil Velikov [Fri, 6 Feb 2026 20:38:18 +0000 (20:38 +0000)] 
meson: bump minimal openssl/libcrypto to 3.0.0

OpenSSL 3.0 introduces semantic versioning, thus one can reason about
the supported (and/or broken) API/ABI by glancing at the number.

Version 3.0 was released in late 2021 and is adopted by, at least:
 - CentOS Stream 9
 - Debian 11 aka oldoldstable
 - Fedora 38
 - openSUSE Leap 15.5
 - Ubuntu 22.04

This means that some older, yet maintained, enterprise-y linuxes will be
left in the dark. Namely:
 - RHEL 6,7
 - SLES 11,12,15?
 - Ubuntu {14,16,18,20}.04

To the best of my knowledge, all of them are in deep maintenance mode
and do not target latest kmod releases.

Bumping the requirement, allows us to focus on a single DSO and its API,
as we move to dlopen(libcrypto.so) with the next commit(s).

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/420
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
3 months agoshared: util.c: fix buffer overflow in alias_normalize()
Anton Moryakov [Tue, 10 Mar 2026 16:07:15 +0000 (19:07 +0300)] 
shared: util.c: fix buffer overflow in alias_normalize()

The while-loop inside the '[' case of alias_normalize() increments the
index 'i' without checking against PATH_MAX bounds. If the input string
contains an opening '[' followed by many characters without a closing ']',
the index can exceed PATH_MAX-1, causing a buffer overflow when writing
to buf[i].

Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/431
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
3 months agolibkmod/libkmod-signature: rework struct kmod_signature_info
Emil Velikov [Sun, 15 Feb 2026 21:34:01 +0000 (21:34 +0000)] 
libkmod/libkmod-signature: rework struct kmod_signature_info

Currently, we use a stack allocated instance which bolts of misc private
data via a void *, while also having an optional free callback.

In kmod we opt to pre-calculate the total size, do a one-off allocation,
copy the data as needed, adjusting the pointers.

Doing the same here, gives us a mixed bag of benefits:
 - shorter and simpler code
 - smaller binary - ~100 bytes off
 - fewer instructions - ~40 per module
 - few allocations - ~2 per module
 - extra bytes are allocated - ~180 per module

The updated code seems far more natural and consistent with the
code-base. Although, if we really want to squeeze more cycles we could
use a reasonably large stack buffer and fallback to heap.

v2:
 - don't leak on d2i_PKCS7_bio failure
 - use +1 (instead of sizeof('\0')) for the null terminator

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/427
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
3 months agolibkmod/libkmod-signature: const annotate some stack vars
Emil Velikov [Sun, 15 Feb 2026 21:34:01 +0000 (21:34 +0000)] 
libkmod/libkmod-signature: const annotate some stack vars

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/427
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
3 months agolibkmod/libkmod-signature: remove a few local variables
Emil Velikov [Sun, 15 Feb 2026 21:34:01 +0000 (21:34 +0000)] 
libkmod/libkmod-signature: remove a few local variables

Drop a couple of the local variables, which are used only once. They
make the, arguably convoluted, code even harder to follow.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/427
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
3 months agolibkmod/libkmod-signature: fold a few NULL checks
Emil Velikov [Sun, 15 Feb 2026 21:34:01 +0000 (21:34 +0000)] 
libkmod/libkmod-signature: fold a few NULL checks

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/427
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
3 months agolibkmod/libkmod-signature: remove set but unused sig_alg
Emil Velikov [Sun, 15 Feb 2026 21:34:01 +0000 (21:34 +0000)] 
libkmod/libkmod-signature: remove set but unused sig_alg

The function PKCS7_SIGNER_INFO_get0_algs takes three output arguments,
all of which are optional. Remove the set but unused sig_alg.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/427
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
3 months agolibkmod/libkmod-signature: drop pkcs7_private::key_id sign-ness
Emil Velikov [Sun, 15 Feb 2026 21:34:01 +0000 (21:34 +0000)] 
libkmod/libkmod-signature: drop pkcs7_private::key_id sign-ness

There is no signed/unsigned declaration in kmod_signature_info, so let's
do the same for the private declaration.

Silence BN_bn2bin(), by applying the cast locally.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/427
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
3 months agolibkmod/libkmod-signature: remove kmod_signature_info::algo
Emil Velikov [Sun, 15 Feb 2026 21:34:01 +0000 (21:34 +0000)] 
libkmod/libkmod-signature: remove kmod_signature_info::algo

Allegedly it has been hard-coded to RSA for ages and thus, it was
never printed by modinfo.

Furthermore out of the 3 code-paths only a single one parses it...

Just drop the dead code adding a somewhat helpful comment for future
code explorers.

Thus shaves ~150 bytes off the binary and allows us to shrink the
struct.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/427
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
3 months agolibkmod/libkmod-signature: move sig_info->id_type assignment further up
Emil Velikov [Sun, 15 Feb 2026 21:34:01 +0000 (21:34 +0000)] 
libkmod/libkmod-signature: move sig_info->id_type assignment further up

It is identical across all the (3) code paths. So move it to the caller,
thus we no longer need to pass the struct module_signature in the PKCS7
case.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/427
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
3 months agolibkmod/libkmod-signature: remove ENABLE OPENSSL comments
Emil Velikov [Sun, 15 Feb 2026 21:34:01 +0000 (21:34 +0000)] 
libkmod/libkmod-signature: remove ENABLE OPENSSL comments

Having the guard repeated in the else/endif lines is generally a good
idea. Although in this case a) it has a typo (missing _) and b) no other
part of the code-base does it.

Just remove the instances for consistency sake.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/427
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
3 months agotestsuite: reshuffle preload env. variable handling
Emil Velikov [Fri, 13 Feb 2026 19:52:35 +0000 (19:52 +0000)] 
testsuite: reshuffle preload env. variable handling

Get the existing LD_PRELOAD early and do a two pass on the rest.

Effectively calculate the total length, allocate and copy... Instead of
the existing recalc, realloc, copy.

Fewer allocations (failure points), while also being a bit simpler and
shorter code.

v2:
 - append existing ldpreload

v3:
 - revert to prepending, do so only as needed

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/429
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
3 months agotestsuite: fold setenv() in single block(ish)
Emil Velikov [Fri, 13 Feb 2026 19:52:35 +0000 (19:52 +0000)] 
testsuite: fold setenv() in single block(ish)

... to make it stand out from all the realloc/copying.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/429
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
3 months agolibkmod: fold kmod_file_{load_content,get_{content,size}}
Emil Velikov [Fri, 6 Feb 2026 19:35:15 +0000 (19:35 +0000)] 
libkmod: fold kmod_file_{load_content,get_{content,size}}

Currently, the kmod_file data fits in two groups:
 - populated on initialization (aka kmod_file_open)- fd, compression
 - populated on kmod_file_load_contents - contents, size

Currently, the caller has to track/remember kmod_file_load_contents
prior to calling the contents/size getters...

At the same time, we don't need the fine grained API since all call
sites need both contents and size. So let's just fold the three
together.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
---
Not a huge fan of the casts, although we already use similar approach in
kmod_module_load_elf and others.

Don't mind going either way - keep the casts or drop the const.

Link: https://github.com/kmod-project/kmod/pull/418
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
3 months agolibkmod: tweak kmod_module_get_elf()
Emil Velikov [Wed, 4 Feb 2026 15:12:48 +0000 (15:12 +0000)] 
libkmod: tweak kmod_module_get_elf()

As of last commit, the kmod_elf is stored in the kmod_module instance.
Thus we no longer need the getter and the stack kmod_elf pointer.

Rename the function to kmod_module_load_elf() to align with rest of the
codebase, dropping the elf output pointer - callers can access it
directly via the kmod_module struct.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/418
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>