]> git.ipfire.org Git - thirdparty/kmod.git/log
thirdparty/kmod.git
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>
4 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
4 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>
4 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>
4 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>
4 months agoRemove the softdep modinfo in the modules mod-softdep-a and mod-softdep-b
He Dan [Fri, 28 Mar 2025 15:06:13 +0000 (23:06 +0800)] 
Remove the softdep modinfo in the modules mod-softdep-a and mod-softdep-b

Since the soft dependencies are defined in modprobe config, we do not
have to add those info in the modinfo section of the modules.

Co-developed-by: Dan He <dan.h.he@intel.com>
Signed-off-by: Dan He <dan.h.he@intel.com>
Co-developed-by: Gongjun Song <gongjun.song@intel.com>
Signed-off-by: Gongjun Song <gongjun.song@intel.com>
Signed-off-by: Yuchi Chen <yuchi.chen@intel.com>
Signed-off-by: Wenjie Wang <wenjie2.wang@intel.com>
Signed-off-by: Qingqing Li <qingqing.li@intel.com>
Signed-off-by: He Dan <dan.h.he@intel.com>
Link: https://github.com/kmod-project/kmod/pull/311
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agoAdded the test case of using multiple softdep for a module
Gongjun Song [Fri, 7 Mar 2025 15:03:18 +0000 (23:03 +0800)] 
Added the test case of using multiple softdep for a module

We defined two modules mod-softdep-a and mod-softdep-b. The softdep
statements are split into two separate modprobe configure files.

The unit test case is supposed to fail, since the libkmod will take
only the first softdep statement based on the current implementation.

Co-developed-by: Dan He <dan.h.he@intel.com>
Signed-off-by: Dan He <dan.h.he@intel.com>
Co-developed-by: Gongjun Song <gongjun.song@intel.com>
Signed-off-by: Gongjun Song <gongjun.song@intel.com>
Signed-off-by: Yuchi Chen <yuchi.chen@intel.com>
Signed-off-by: Wenjie Wang <wenjie2.wang@intel.com>
Signed-off-by: Qingqing Li <qingqing.li@intel.com>
Link: https://github.com/kmod-project/kmod/pull/311
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agotools/rmmod: fix garbled error message
Yannick Le Pennec [Mon, 24 Mar 2025 17:35:53 +0000 (18:35 +0100)] 
tools/rmmod: fix garbled error message

a6f9cd0 ("tools/rmmod: consistently use ERR logging facility") fixed
the split between syslog and stderr of various error message substrings
by calling the ERR macro instead of writing directly to stderr, but in
doing so also completely mangled the output because the ERR macro
decorates its arguments:

    $ rmmod iwlwifi
    rmmod: ERROR: Module iwlwifi is in use by:rmmod: ERROR:  iwlmvmrmmod: ERROR:

And in syslog:

    $ rmmod -s iwlwifi
    2025-03-24T17:22:34.878318+01:00 mangolassi rmmod: ERROR: Module iwlwifi is in use by:
    2025-03-24T17:22:34.889145+01:00 mangolassi rmmod: ERROR:  iwlmvm
    2025-03-24T17:22:34.889224+01:00 mangolassi rmmod: ERROR:

This commit fixes that by building the holder names list with a strbuf
and then passes the whole thing at once to ERR.

Fixes: a6f9cd0 ("tools/rmmod: consistently use ERR logging facility")
Signed-off-by: Yannick Le Pennec <yannick.lepennec@live.fr>
Link: https://lore.kernel.org/r/VI1PR02MB48291E3BDB7E764ED67154949BA42@VI1PR02MB4829.eurprd02.prod.outlook.com
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/328
4 months agolibkmod: fix buffer-overflow in weakdep_to_char
Tobias Stoeckmann [Wed, 26 Mar 2025 14:51:22 +0000 (15:51 +0100)] 
libkmod: fix buffer-overflow in weakdep_to_char

Fix another buffer overflow which can happen if no weak dependencies
exist. Use the same logic as found in softdep_to_char to cover this
case as well.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/327
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agoREADME: remove autotools instruction
Tobias Stoeckmann [Wed, 26 Mar 2025 15:10:06 +0000 (16:10 +0100)] 
README: remove autotools instruction

The autotools support is gone. Remove it from README.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/326
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agomeson: alpha sort the tests(uite)
Emil Velikov [Mon, 17 Mar 2025 16:29:54 +0000 (16:29 +0000)] 
meson: alpha sort the tests(uite)

Fixes: 9cb87e2d ("testsuite: Improve fake_delete behavior")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/322
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agoci/main: alpha sort distributions/variants
Emil Velikov [Tue, 11 Mar 2025 14:32:37 +0000 (14:32 +0000)] 
ci/main: alpha sort distributions/variants

Fixes: ae7b0c30 ("ci: Test with Debian bullseye")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/322
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agotools: use space for long opts
Emil Velikov [Tue, 11 Mar 2025 12:26:07 +0000 (12:26 +0000)] 
tools: use space for long opts

The getopt_long() API handles both space and = separated long options
just fine. On the other hand, supporting both in the shell completions
means that we'll have to quadruple them in terms of size/complexity.

So let's try to keep things simple and consistent, by recommending only
the space variant.

Make sure to update both the tools' --help and the respective man pages.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/313
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agolibkmod: fix buffer-overflow in weakdep_to_char
Jakub Åšlepecki [Fri, 21 Mar 2025 10:41:35 +0000 (10:41 +0000)] 
libkmod: fix buffer-overflow in weakdep_to_char

modprobe -c with any sample weakdep command in modprobe.d will overflow
memcpy due to size calculation not incorporating trailing null byte,
for example:

==462449==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x50200000067b at pc 0x7a83fe6faf59 bp 0x7ffdf6c25060 sp 0x7ffdf6c24808
WRITE of size 12 at 0x50200000067b thread T0
    0 0x7b687e6faf58 in memcpy /usr/src/debug/gcc/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:115
    1 0x5e22b821235f in weakdep_to_char ../libkmod/libkmod-config.c:623
    2 0x5e22b821235f in weakdep_get_plain_weakdep ../libkmod/libkmod-config.c:1166
    3 0x5e22b821d049 in kmod_config_iter_get_value ../libkmod/libkmod-config.c:1317
    4 0x5e22b81fd5ec in show_config ../tools/modprobe.c:187
    5 0x5e22b81fd5ec in do_modprobe ../tools/modprobe.c:946
    6 0x7b687d635487  (/usr/lib/libc.so.6+0x27487) (BuildId: 0b707b217b15b106c25fe51df3724b25848310c0)
    7 0x7b687d63554b in __libc_start_main (/usr/lib/libc.so.6+0x2754b) (BuildId: 0b707b217b15b106c25fe51df3724b25848310c0)
    8 0x5e22b81da114 in _start ($PWD/kmod+0xaa114) (BuildId: c36444aefc2ca73423765d4ebf017a24e55017ee)

May also appear as:

*** buffer overflow detected ***: terminated
Aborted (core dumped)

Signed-off-by: Jakub Åšlepecki <jakub.slepecki@intel.com>
Link: https://github.com/kmod-project/kmod/pull/324
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Tobias Stoeckmann <tobias@stoeckmann.org>
4 months agotestsuite: Add modprobe -c test for weakdep
Lucas De Marchi [Tue, 25 Mar 2025 17:12:10 +0000 (12:12 -0500)] 
testsuite: Add modprobe -c test for weakdep

Currently failing due to buffer overflow, as reported and fixed
in https://github.com/kmod-project/kmod/pull/324.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/324
4 months agoci: Improve double checkout where needed
Lucas De Marchi [Wed, 12 Mar 2025 16:20:32 +0000 (11:20 -0500)] 
ci: Improve double checkout where needed

In the main workflow the problem needing a double checkout is that
git may not be available in the containers we are using which causes the
action/checkout to use a tarball. However some of the steps (e.g. meson
dist) need the checkout to be a real git checkout.

Improve the double checkout by doing the first checkout to a local-actions
directory that can be removed after the setup is done. Even if doing it
in a separate dir, the CWD still belongs to a different user as
additional debugs show before removing that directory:

ls -la .
total 12
drwxr-xr-x  3 1001  118 4096 Mar 12 18:35 .
drwxr-xr-x  3 1001  118 4096 Mar 12 18:35 ..
drwxr-xr-x 10 root root 4096 Mar 12 18:35 local-actions

ls -la ..
total 12
drwxr-xr-x 3 1001  118 4096 Mar 12 18:35 .
drwxr-xr-x 6 1001 root 4096 Mar 12 18:35 ..
drwxr-xr-x 3 1001  118 4096 Mar 12 18:35 kmod

Move the safe directory setting to the cleanup step.

Another alternative would be to use the setup-os action from a "remote"
repository, i.e. kmod-project/kmod/.github/actions/setup-os. However it
would make harder to update it in PRs since it would fetch the action
from a different branch.

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/321
4 months agoci: Drop double checkout where not needed
Lucas De Marchi [Wed, 12 Mar 2025 16:11:51 +0000 (11:11 -0500)] 
ci: Drop double checkout where not needed

The only workflow that needs a double checkout is the main one, all the
others should be fine without.

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/321
4 months agoci: Drop container objects for other workflows
Lucas De Marchi [Wed, 12 Mar 2025 15:53:45 +0000 (10:53 -0500)] 
ci: Drop container objects for other workflows

Commit 23b45fc385c7 ("ci: Drop container object") dropped the container
object for the main workflow. Do the same for the other workflows.
Even if they don't need a matrix (since they run in just one
configuration), keep using it to make the structure common to all
workflows.

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/321
4 months agoci: Generalize OS setup in one action
Lucas De Marchi [Wed, 12 Mar 2025 13:55:03 +0000 (08:55 -0500)] 
ci: Generalize OS setup in one action

Use just one action for OS setup and make it call the right script. This
makes it easier to maintain as when devs are working with containers,
they can just call the script, and it also avoids repeated conditional
steps in the workflows.

If a distro is not supported, the action will simply fail and support
may be added later.

With the move to .sh files, also run shellcheck in them: surprisingly
just one quote missing.

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/321
4 months agoci: remove Debian/pahole dependency
Emil Velikov [Tue, 11 Mar 2025 12:46:10 +0000 (12:46 +0000)] 
ci: remove Debian/pahole dependency

The dependency was added as a workaround to the Debian bug linked. With
that resolved we can remove pahole.

Reference: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1098706
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/314
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agoci: remove no longer needed libtool
Emil Velikov [Tue, 11 Mar 2025 14:22:46 +0000 (14:22 +0000)] 
ci: remove no longer needed libtool

We've dropped libtool across all distros but Fedora. The tool is not
needed anymore, so let's remove it.

Fixes: 04520dc9 ("ci: Remove autotools dependencies from containers")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/318
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agoNEWS: squash a couple of typos
Emil Velikov [Tue, 11 Mar 2025 12:49:54 +0000 (12:49 +0000)] 
NEWS: squash a couple of typos

Namely:
 - ondemand -> on demand
 - mson -> meson

Fixes: 88940379 ("kmod 34")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/315
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agotestsuite/test-remove: add license/copyright notice
Emil Velikov [Tue, 11 Mar 2025 13:21:16 +0000 (13:21 +0000)] 
testsuite/test-remove: add license/copyright notice

Fixes: 9cb87e2d ("testsuite: Improve fake_delete behavior")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/316
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agoci: Push documentation to kmod-project.github.io and trigger publishing
Chen, Yuchi [Fri, 7 Mar 2025 05:15:01 +0000 (13:15 +0800)] 
ci: Push documentation to kmod-project.github.io and trigger publishing

1. When master or a new tag is pushed, build API documentation
2. Push the newly built document to kmod-project.github.io
3. Dispatch kmod-project.github.io to publish documents

Co-developed-by: Chen, Yuchi <yuchi.chen@intel.com>
Signed-off-by: Chen, Yuchi <yuchi.chen@intel.com>
Signed-off-by: Gongjun Song <gongjun.song@intel.com>
Signed-off-by: Dan He <dan.h.he@intel.com>
Signed-off-by: Wenjie Wang <wenjie2.wang@intel.com>
Signed-off-by: Qingqing Li <qingqing.li@intel.com>
Link: https://github.com/kmod-project/kmod/pull/308
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agoci: bump the all-actions group across 1 directory with 2 updates
dependabot[bot] [Sat, 1 Mar 2025 01:10:03 +0000 (01:10 +0000)] 
ci: bump the all-actions group across 1 directory with 2 updates

Bumps the all-actions group with 2 updates in the / directory: [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.27.1 to 3.28.10
- [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/4f3212b61783c3c68e8309a0f18a699764811cda...b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d)

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

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-actions
- dependency-name: codecov/codecov-action
  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/302
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agoshared: improve strbuf_reserve_extra performance
Tobias Stoeckmann [Fri, 28 Feb 2025 16:27:12 +0000 (17:27 +0100)] 
shared: improve strbuf_reserve_extra performance

If strbuf is used (depmod, modprobe -c) then strbuf_reserve_extra is
performance critical. This reduces amount of instructions for
modprobe -c by around 10 %, the total instruction count for depmod
by 1 % (majority is within reading module files).

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/296
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agoshared: turn strbuf_reserve_extra private
Tobias Stoeckmann [Mon, 24 Feb 2025 19:20:50 +0000 (20:20 +0100)] 
shared: turn strbuf_reserve_extra private

We can make it public if it's needed again.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/296
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agodepmod: remove strbuf_reserve_extra call
Tobias Stoeckmann [Mon, 24 Feb 2025 19:14:37 +0000 (20:14 +0100)] 
depmod: remove strbuf_reserve_extra call

The strbuf_reserve_extra call is only left for a possible '/' addition,
which only occurs before depmod_modules_search_dir recursively calls
itself.

By adding the slash at the start, it also simplifies
depmod_modules_search_path which does not have to do this before calling
depmod_modules_search_dir on its own.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/296
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agodepmod: refactor depmod_modules_search_dir
Tobias Stoeckmann [Mon, 24 Feb 2025 19:11:14 +0000 (20:11 +0100)] 
depmod: refactor depmod_modules_search_dir

The function depmod_modules_search_dir is supposed to ignore all errors
encountered during directory entry iteration. This was not true for
out of memory conditions, which could also lead to wrong output.

Clarify this fact by turning it void and adjust callers accordingly.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/296
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agoshared: let strbuf_str never fail
Tobias Stoeckmann [Mon, 24 Feb 2025 19:07:05 +0000 (20:07 +0100)] 
shared: let strbuf_str never fail

The strbuf functionality is always used to create C strings, so already
reserve an extra byte for NUL whenever size allocations occur.

Together with the fact that strbuf_str already returns a const char *,
an empty strbuf may return an unmodifiable empty string.

This renders all strbuf_str return value checks obsolete.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/296
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agoshared: drop strbuf_steal
Tobias Stoeckmann [Mon, 24 Feb 2025 19:03:05 +0000 (20:03 +0100)] 
shared: drop strbuf_steal

The only use case of strbuf_steal is gone. If the requirement for this
function returns, we can add it again.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/296
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agolibkmod: refactor kmod_module_hex_to_str
Tobias Stoeckmann [Mon, 24 Feb 2025 18:55:28 +0000 (19:55 +0100)] 
libkmod: refactor kmod_module_hex_to_str

The hex output uses a heap-based strbuf. It can be turned into a
stack-based strbuf by refactoring kmod_module_hex_to_str. Instead of
returning a C string, a supplied strbuf can be filled with hex values
in ASCII representation. Renamed to kmod_module_strbuf_pushhex.

A size of 512 is sufficient for signatures on Arch Linux and removes
heap allocations. Additional benefit is implicit strbuf_init and
strbuf_release due to DECLARE_STRBUF_WITH_STACK.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/296
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agodepmod: use stack strbuf where possible
Tobias Stoeckmann [Mon, 24 Feb 2025 18:49:40 +0000 (19:49 +0100)] 
depmod: use stack strbuf where possible

The deps bin output uses a strbuf. A size of 2048 covers all cases
on current Arch Linux (max used size is 1548) and removes heap
allocations.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/296
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agolibkmod: use stack strbuf for index processing
Tobias Stoeckmann [Mon, 24 Feb 2025 18:48:05 +0000 (19:48 +0100)] 
libkmod: use stack strbuf for index processing

The strbuf content is never returned, so it's easy to switch to a
stack-based solution. It removes heap allocations and the need to
manually call strbuf_init and strbuf_release since these are covered
through DECLARE_STRBUF_WITH_STACK as well.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/296
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agolibkmod: release memory on builtin error path
Tobias Stoeckmann [Sat, 22 Feb 2025 18:53:43 +0000 (19:53 +0100)] 
libkmod: release memory on builtin error path

If the modules.builtin.modinfo file contains valid and invalid
lines, it is possible that libkmod leaks memory on error path.

Let strbuf API take care to always release strbuf and reset it
if allocated heap memory is taken away from it.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/291
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agomodinfo: reduce amount of continue statements
Tobias Stoeckmann [Sat, 22 Feb 2025 14:24:33 +0000 (15:24 +0100)] 
modinfo: reduce amount of continue statements

Clarify that the code does not perform error checks, for which we
regularly use checks and continue at the start, but merely checks
how to print/filter the data.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/290
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agotestsuite: Improve fake_delete behavior
Gongjun Song [Fri, 7 Mar 2025 02:33:51 +0000 (10:33 +0800)] 
testsuite: Improve fake_delete behavior

- When fake delete_module() succeeds, remove its entry from /sys/module.
- Add tests to ensure module is properly removed.

Co-developed-by: Qingqing Li <qingqing.li@intel.com>
Signed-off-by: Qingqing Li <qingqing.li@intel.com>
Signed-off-by: Dan He <dan.h.he@intel.com>
Signed-off-by: Gongjun Song <gongjun.song@intel.com>
Signed-off-by: Yuchi Chen <yuchi.chen@intel.com>
Signed-off-by: Wenjie Wang <wenjie2.wang@intel.com>
Link: https://github.com/kmod-project/kmod/pull/309
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agoci: Test with different moduledir
Lucas De Marchi [Tue, 4 Mar 2025 21:57:21 +0000 (15:57 -0600)] 
ci: Test with different moduledir

Add a test for a common setup (/usr/lib/modules) and a weird one
(/kernel-modules) to cover uses of moduledir.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agomeson: Show compiler and linker in summary
Lucas De Marchi [Fri, 28 Feb 2025 14:44:55 +0000 (08:44 -0600)] 
meson: Show compiler and linker in summary

Make it easy to identify the compiler and linker being used.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agoci: Add pipeline to test linking with lld
Lucas De Marchi [Mon, 6 Jan 2025 16:37:56 +0000 (10:37 -0600)] 
ci: Add pipeline to test linking with lld

Test linking with lld to avoid issues like
https://github.com/kmod-project/kmod/issues/269

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agoci: Switch most builds to 64b
Lucas De Marchi [Thu, 27 Feb 2025 16:47:08 +0000 (10:47 -0600)] 
ci: Switch most builds to 64b

Due to a mistake on using "multilib" fixed in commit
271d8ab ("ci: Fix 32b build ignoring options") and commit
6897912 ("ci: s/multilib/x32/"), most of our builds were actually
testing 32b, which is not the most common thing.

Leave just 2 32b builds, one with Archlinux and the other with Ubuntu
and remove the FIXME about configuration.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agoci: Fix 32b build ignoring options
Lucas De Marchi [Thu, 27 Feb 2025 14:48:56 +0000 (08:48 -0600)] 
ci: Fix 32b build ignoring options

In some configurations we pass meson_setup and x32 options, but the
options were being ignored in 32b builds. Unify the configure/build/test
steps since just the 32b configuration step that needs to be handled
differently, then make sure --native-file and the configure options
are also handled for 32b builds.

Add a 64b configuration for Archlinux and disable test on Archlinux x32
since it's failing due to packages installed and/or distro
configuration.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agoci: s/multilib/x32/
Lucas De Marchi [Thu, 27 Feb 2025 14:38:19 +0000 (08:38 -0600)] 
ci: s/multilib/x32/

It's confusing using "multilib" because it's not about adding the
"capability of building 32b", it's rather "this is really building and
testing 32b, which takes different steps.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agoci: Test with Debian bullseye
Lucas De Marchi [Wed, 26 Feb 2025 03:24:58 +0000 (21:24 -0600)] 
ci: Test with Debian bullseye

This is used to build LibreELEC as per
https://github.com/kmod-project/kmod/issues/298. Test with it.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agoci: Drop container object
Lucas De Marchi [Thu, 27 Feb 2025 08:06:31 +0000 (02:06 -0600)] 
ci: Drop container object

Just use all the properties in a single level rather than embeding it in
the container object.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agoci: Use include to completly specify the matrix
Lucas De Marchi [Thu, 27 Feb 2025 06:36:33 +0000 (00:36 -0600)] 
ci: Use include to completly specify the matrix

The permutation available in github and extending it "include" or
reducing it with "exclude" are much harder than needed. It doesn't seem
we can have a mix of "properties" with the configurations. Just give up
and completly specify the matrix. Now that there's only 1 build system,
at least doing all the permutations doesn't make it too big.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agobuild: Drop autotools
Lucas De Marchi [Fri, 21 Feb 2025 23:09:37 +0000 (17:09 -0600)] 
build: Drop autotools

Simplify our lives by handling just one build system.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agoci: Remove autotools dependencies from containers
Lucas De Marchi [Fri, 21 Feb 2025 23:06:55 +0000 (17:06 -0600)] 
ci: Remove autotools dependencies from containers

Not needed anymore.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agoci: Drop autotools builds
Lucas De Marchi [Fri, 21 Feb 2025 23:05:00 +0000 (17:05 -0600)] 
ci: Drop autotools builds

Not needed anymore.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agomeson: Fix setting an absolute customdir
Hendrik Donner [Mon, 3 Mar 2025 15:10:56 +0000 (16:10 +0100)] 
meson: Fix setting an absolute customdir

The path join operator / does not add a leading path seperator.

Signed-off-by: Hendrik Donner <hd@os-cillation.de>
Link: https://github.com/kmod-project/kmod/pull/303
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
4 months agomeson: Use short options for ln everywhere
Hendrik Donner [Mon, 3 Mar 2025 15:13:01 +0000 (16:13 +0100)] 
meson: Use short options for ln everywhere

Some implementations of ln (toybox, busybox) typically only support the
short option format, so use it consistently.

The short options are already used in other places and it's usually
supported on more implementations: -s and -f are POSIX and the few
ln that support --relative understand -r. Which are GNU coreutils,
the Rust uutils coreutils, toybox (-r only) and there is an old
patch for busybox (-r only). The BSDs and MacOS don't seem to
support --relative at all.

Signed-off-by: Hendrik Donner <hd@os-cillation.de>
Link: https://github.com/kmod-project/kmod/pull/303
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
5 months agolibkmod: Fix UB for non-existent keys
Lucas De Marchi [Thu, 27 Feb 2025 15:40:11 +0000 (09:40 -0600)] 
libkmod: Fix UB for non-existent keys

When running the testsuite with UBSAN and a non-existent info key is
used, the following happens:

TESTSUITE: running test_modinfo_sig_hashalgo, in forked context
TESTSUITE: ERR: 'test_modinfo_sig_hashalgo' [4212] terminated by signal 6 (Aborted)
TESTSUITE: ------
TESTSUITE: running test_modinfo_sig_key, in forked context
TESTSUITE: ERR: 'test_modinfo_sig_key' [4292] terminated by signal 6 (Aborted)
TESTSUITE: ------
TESTSUITE: running test_modinfo_signer, in forked context
TESTSUITE: ERR: 'test_modinfo_signer' [4348] terminated by signal 6 (Aborted)

In CI this happens when disabling module signature handling with
-D openssl=disabled. The UBSAN report is as below:

../dist-unpack/kmod-34/libkmod/libkmod-module.c:1773:2: runtime error: null pointer passed as argument 2, which is declared to never be null
    #0 0x55bb657aa13b  (/__w/kmod/kmod/build/meson-private/dist-build/kmod+0x9f13b) (BuildId: 2c8f9c0ffdbcdf249a3cca29a9d2bc47f706a324)
    #1 0x55bb6580a4be  (/__w/kmod/kmod/build/meson-private/dist-build/kmod+0xff4be) (BuildId: 2c8f9c0ffdbcdf249a3cca29a9d2bc47f706a324)
    #2 0x55bb657cc360  (/__w/kmod/kmod/build/meson-private/dist-build/kmod+0xc1360) (BuildId: 2c8f9c0ffdbcdf249a3cca29a9d2bc47f706a324)
    #3 0x55bb657cdf43  (/__w/kmod/kmod/build/meson-private/dist-build/kmod+0xc2f43) (BuildId: 2c8f9c0ffdbcdf249a3cca29a9d2bc47f706a324)
    #4 0x7f0651bb3487  (/usr/lib/libc.so.6+0x27487) (BuildId: 0b707b217b15b106c25fe51df3724b25848310c0)
    #5 0x7f0651bb354b  (/usr/lib/libc.so.6+0x2754b) (BuildId: 0b707b217b15b106c25fe51df3724b25848310c0)
    #6 0x55bb657aeb14  (/__w/kmod/kmod/build/meson-private/dist-build/kmod+0xa3b14) (BuildId: 2c8f9c0ffdbcdf249a3cca29a9d2bc47f706a324)

Keep the current behavior of appending a 0-length value, just skipping
the pointless memcpy.

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/300
5 months agomeson: Fix build with glibc 2.31
Lucas De Marchi [Tue, 25 Feb 2025 14:49:50 +0000 (08:49 -0600)] 
meson: Fix build with glibc 2.31

In order to use dlopen it may be required to link with libdl depending
on the libc. Add the proper dependency to fix the build in Debian
Bullseye.

Closes: https://github.com/kmod-project/kmod/issues/298
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/299
5 months agobuild: support missing gtkdocize in releases
Tobias Stoeckmann [Mon, 24 Feb 2025 18:34:10 +0000 (19:34 +0100)] 
build: support missing gtkdocize in releases

The release tarballs may already contain symbolic links into the
file system for gtk-doc specific files.

If gtk-doc is not installed, and thus not desired for building,
remove the symbolic links and create empty files instead.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/295
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
5 months agoci: add pahole for Debian unstable
Tobias Stoeckmann [Mon, 24 Feb 2025 16:12:24 +0000 (17:12 +0100)] 
ci: add pahole for Debian unstable

The pahole package is required in our test suite for module creation:

  BTF [M] /__w/kmod/kmod/build/testsuite/module-playground/mod-simple.ko
/bin/sh: 1: pahole: not found
make[3]: *** [/usr/src/linux-headers-6.12.16-common/scripts/Makefile.modfinal:64: /__w/kmod/kmod/build/testsuite/module-playground/mod-simple.ko] Error 127

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/294
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
5 months agoNEWS: ditch mention of libxz.so
Jan Engelhardt [Fri, 21 Feb 2025 22:43:42 +0000 (23:43 +0100)] 
NEWS: ditch mention of libxz.so

There is no libxz.so; xz produces liblzma.so.N.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Link: https://github.com/kmod-project/kmod/pull/288
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
5 months agokmod 34 v34
Lucas De Marchi [Fri, 21 Feb 2025 20:28:48 +0000 (14:28 -0600)] 
kmod 34

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
5 months agobuild: Run autogen.sh for autotools compatibility
Lucas De Marchi [Tue, 18 Feb 2025 14:58:41 +0000 (08:58 -0600)] 
build: Run autogen.sh for autotools compatibility

When generating the dist archive, run autogen.sh so the tarball can also
be used by distros using autotools.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
5 months agobuild: Drop NEWS-checking from autotools
Lucas De Marchi [Mon, 17 Feb 2025 17:08:21 +0000 (11:08 -0600)] 
build: Drop NEWS-checking from autotools

Help with the build transition and release.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
5 months agokmod: use program_invocation_short_name more often
Tobias Stoeckmann [Wed, 19 Feb 2025 18:18:23 +0000 (19:18 +0100)] 
kmod: use program_invocation_short_name more often

Remove the explicit basename(argv[0]) calls because we already
rely on program_invocation_short_name even before reaching
these lines. Unifies code and slightly reduces binary size.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/284
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
5 months agostatic-nodes: unify return statements
Tobias Stoeckmann [Wed, 19 Feb 2025 18:35:51 +0000 (19:35 +0100)] 
static-nodes: unify return statements

The write_* functions have different return statement handling. Unify
them by removing "else" if the if-block itself returns and also unify
the error handling by checking for the error case, leaving the success
return statement at the end of the function.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/285
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
5 months agomodprobe: unify help output
Tobias Stoeckmann [Wed, 19 Feb 2025 21:21:48 +0000 (22:21 +0100)] 
modprobe: unify help output

Add = to modprobe help output for --wait to comply with all other long
option descriptions.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/287
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
5 months agoman: add -h explanation to modinfo.8
Tobias Stoeckmann [Wed, 19 Feb 2025 21:19:00 +0000 (22:19 +0100)] 
man: add -h explanation to modinfo.8

Unifiy modinfo.8 with other manual pages by also explaining what
-h option does.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/287
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
5 months agoman: use = for long options
Tobias Stoeckmann [Wed, 19 Feb 2025 21:13:31 +0000 (22:13 +0100)] 
man: use = for long options

Stay in sync with other manual pages like the ones from coreutils
and the -h output of kmod tools.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/287
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
5 months agostatic-nodes: do not open /dev/stdout explicitly
Tobias Stoeckmann [Tue, 18 Feb 2025 21:40:40 +0000 (22:40 +0100)] 
static-nodes: do not open /dev/stdout explicitly

If no -o option is given, use stdout directly without opening
/dev/stdout manually. In a chroot environment, this could lead
to /dev/stdout creation as a regular file.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/283
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
5 months agolibkmod: Check correct ELF header size
Tobias Stoeckmann [Sat, 15 Feb 2025 21:03:34 +0000 (22:03 +0100)] 
libkmod: Check correct ELF header size

Check if enough bytes are available for Elf32_Ehdr, not Elf32_Shdr.
The size of Elf32_Shdr is needed later on.

Since both are 64 bytes, no functional change.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/279
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
5 months agolog: fix style
Tobias Stoeckmann [Tue, 18 Feb 2025 21:25:51 +0000 (22:25 +0100)] 
log: fix style

Add a missing newline between two functions.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/282
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
5 months agomodprobe: reduce visibility of use_syslog
Tobias Stoeckmann [Tue, 18 Feb 2025 21:25:05 +0000 (22:25 +0100)] 
modprobe: reduce visibility of use_syslog

The use_syslog variable is only used within main function, so reduce
its visibility.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/282
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
5 months agotools: use bool instead of int for log_open
Tobias Stoeckmann [Tue, 18 Feb 2025 21:20:46 +0000 (22:20 +0100)] 
tools: use bool instead of int for log_open

Since log_open takes a booln as argument, turn use_syslog into a
bool instead of using an int. Shrinks binary size with GCC and from
C point of view, this makes the code cleaner.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/282
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
5 months agostrbuf: Remove alloca.h include
Lucas De Marchi [Sat, 15 Feb 2025 01:18:43 +0000 (19:18 -0600)] 
strbuf: Remove alloca.h include

This is not used anymore.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
6 months agoci: Stop using ubuntu-latest
Lucas De Marchi [Mon, 6 Jan 2025 19:14:05 +0000 (13:14 -0600)] 
ci: Stop using ubuntu-latest

This generates a bunch of warnings in CI

ubuntu-latest pipelines will use ubuntu-24.04 soon. For more details,
see https://github.com/actions/runner-images/issues/10636

Update to ubuntu 24.04 to catch any possible issues and stop using
ubuntu-latest.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
6 months agotestsuite: Assert a test binary is non-empty
Lucas De Marchi [Mon, 6 Jan 2025 16:07:07 +0000 (10:07 -0600)] 
testsuite: Assert a test binary is non-empty

Avoid issues like https://github.com/kmod-project/kmod/issues/269
by asserting the test binary is non-empty:

Suggested-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
6 months agoclang-format: Add new attribute macros
Lucas De Marchi [Mon, 6 Jan 2025 15:16:13 +0000 (09:16 -0600)] 
clang-format: Add new attribute macros

Commits 44855d7 ("shared/macro: Add _alignedptr_") and d7e7c4c
("shared/macro: Add macros for more attributes") added the macros, but
forgot to add them to the clang-format configuration.

Suggested-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>