Commit Graph

1887 Commits

Author SHA1 Message Date
Emil Velikov
5c24480dff depmod: Remove a malloc call
The offsets of node children can be stored on stack.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/188
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-13 08:56:11 -06:00
Tobias Stoeckmann
dada048cbf depmod: Write index in pre-order
Index files in pre-order have a significant performance improvement
for libkmod users.

On Arch Linux system, dumping configuration takes 296 read calls
in pre-order, compared to 4080 in post-order. Tests on a Raspberry
Pi 2 test system have shown an improvement by 9 %.

Even writing is faster now. This happens because we must know in
advance how many bytes index nodes will consume in the resulting file.
Although this code calculates it on the fly and caches the results,
saving lseek system calls has a significant positive effect which
compensates this extra overhead.

On Arch Linux system, writing index takes 6143 lseek calls now, compared
to previous 83701, leading to a performance gain of 13 %.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/188
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-13 08:56:11 -06:00
Emil Velikov
a076809c96 meson: undefine NDEBUG in the tests
When using -D b_ndebug=true or inheriting CFLAGS="-DNDEBUG" from the
environment, the asserts will be no-op thus the checks in the
LD_PRELOADED libraries will be omitted.

Explicitly undefine the macro, so we don't accidentally shoot ourselves
in the foot.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/238
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-11 18:22:01 -06:00
dependabot[bot]
1ae4c61082 ci: bump the all-actions group across 1 directory with 3 updates
Bumps the all-actions group with 3 updates in the / directory: [actions/checkout](https://github.com/actions/checkout), [yshui/git-clang-format-lint](https://github.com/yshui/git-clang-format-lint) and [github/codeql-action](https://github.com/github/codeql-action).

Updates `actions/checkout` from 4.1.7 to 4.2.2
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](692973e3d9...11bd71901b)

Updates `yshui/git-clang-format-lint` from 1.16 to 1.17
- [Release notes](https://github.com/yshui/git-clang-format-lint/releases)
- [Commits](a65b466f59...27f3890c66)

Updates `github/codeql-action` from 3.26.7 to 3.27.1
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](8214744c54...4f3212b617)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-actions
- dependency-name: yshui/git-clang-format-lint
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-actions
- dependency-name: github/codeql-action
  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/237
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-11 18:20:24 -06:00
Tobias Stoeckmann
b6b27d3726 libkmod: Fix overflow in kmod_module_hex_to_str
If an overly long signature is found in a module file, it is possible to
trigger an out of boundary write in kmod_module_hex_to_str due to
integer and subsequent heap buffer overflow.

This approach replaces malloc + sprintf with a simple hex-lookup and a
strbuf approach, being slightly faster in real life scenarios while
adding around 100 bytes to library size. A much faster approach could be
done without strbuf and using our overflow check functions, but
readability should win here.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/236
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-11 18:15:37 -06:00
Tobias Stoeckmann
7ff978b482 libkmod: Avoid overflows while parsing files
Specially crafted files could overflow internal counters, allowing out of
boundary writes. Make sure that neither counters nor resulting calculations
overflow.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/234
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-11 18:14:29 -06:00
Lucas De Marchi
28ba117fc6 tree-wide: Sprinkle _clang_suppress_alloc_
Add the clang::suppress attribute to places where allocation is done and
that rely on the cleanup attribute. Clang analyzer doesn't handle those
(yet), so keep it from giving us false positive.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/233
2024-11-11 18:11:11 -06:00
Lucas De Marchi
5322bb8fd1 libkmod: Simplify lookup_builtin_file()
Use cleanup attribute.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/233
2024-11-11 18:11:11 -06:00
Lucas De Marchi
317f89a59a shared: Ignore clang-analyzer on cleanup attribute
When using the cleanup attribute we know we are not leaking that
allocation. Most of the time the assignment is together with the
declaration, so we can simplify additional clang annotations by making
the cleanup attribute imply clang::suppress.

In cases declaration and assignment are not together, provide
_clang_suppress_alloc_ to annotate the code. That is only defined for
clang analyzer.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/233
2024-11-11 18:11:11 -06:00
Lucas De Marchi
4063401a05 build: Stop warning for attribute clang::suppress
That attribute allows us to instruct the Clang Static Analyzer to stop
giving some false positives. However when building the code (with gcc
and clang) they warn that the attribute is ignored. Just ignore as we
know what the attribute is for.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/233
2024-11-11 18:11:11 -06:00
Lucas De Marchi
f94b5c4c37 shared: Move cleanup attribute
Move to macro.h where other attributes are located. The inline helper
function can also move along as we don't need to keep it separate.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/233
2024-11-11 18:11:11 -06:00
Emil Velikov
f8ed5ee139 man: add modprobe.conf.5 manpage link
Seemingly Fedora and friends have been carrying this one for years. Just
add it to kmod itself so that people using multiple distros have
consistent experience.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/231
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-11 16:12:09 -06:00
Emil Velikov
4b1b5e4130 meson: install the configuration directories
Install the /{etc,usr/lib}/{depmod,modprobe}.d/ configuration
directories as part of out install action.

Currently a handful of distros (Debian, Gentoo, Fedora, Arch) do that
manually, where we can have it in the upstream project instead.

As a pie in the sky idea, in the future we may choose to enforce
particular permissions, ownership, etc and this should make it a little
less fragile across the ecosystem.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/231
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-11 16:12:09 -06:00
Emil Velikov
7eaf41bda7 meson.build: install kmod symlinks to /usr/sbin/
With earlier commit we added support for kmod itself to install the
symlinks to kmod. While it works across the board, some distributions
still support (to varying degree) split /usr/bin and /usr/sbin.

This commit changes the location where those are created and bears no
functional change for merged bin-sbin users. While for split ones, it
follows what distributions are doing to a varying extend:

 - Fedora, Alpine - this commit matches exactly what they do
 - Debian, Yocto - they have an extra /bin/lsmod -> ../sbin/kmod symlink
 - Gentoo - as Debian plus an extra /bin/modinfo -> ../sbin/kmod symlink

Loosely based on a Debian patch by Marco d'Itri.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/231
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-11 16:12:09 -06:00
Emil Velikov
ae16a0277b ci: add coreutils to Alpine
The buxybox version of ln supports only the short options and does not
support -r/--relative.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/231
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-11 16:12:09 -06:00
Emil Velikov
5b72ac7d5b ci: add code coverage via Codecov
Add a simple code coverage pipeline based on the CodeQL one.

Should give us pretty reports in the PRs and web UI with the results. We
can consider having HTML reports on our website (once it's up that is)
in addition or instead of at a future point.

Closes: https://github.com/kmod-project/kmod/issues/61
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/229
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-08 11:51:52 -06:00
Emil Velikov
ebbca1c240 Revert "testsuite/path: match the full rootpath"
This reverts commit ae0c0c4c89.

The commit reasoning was correct, but did not consider the case where
other third-party files are created. Namely: when generating the code
coverage files.

Thus the gcna files were created in $test_rootdir/$abs_top_builddir
which meant they won't get picked when the coverage info/xml/html files
were created and the statistics reported were quite wrong.

Revert the commit and add an inline comment, so we don't feel tempted to
change it in the future.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/229
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-08 11:51:52 -06:00
Emil Velikov
73e46a7795 ci/codeql: use Ubuntu 24.04, adjust build flags
While in here drop the docs and manpages flags - both of those combined
take ~1s of CI time - and disable the sanitizers and tests instead.

This means we no longer get pre-existing code problems in the tests,
which is fine considering the number of pre-existing issues in there.
Another nice side effect is that the pipeline time is reduced by ~50%.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/229
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-08 11:51:04 -06:00
Lucas De Marchi
01c8b02c5a build: Drop define not picked by meson
For almost 13 years, since commit 769becb5db ("tools: kmod: Add
handling of compat modinfo") we have a non-spoken joke in the build
system showing "-DANOTHER_BRICK_IN_THE -Wall" in honour of the famous
Pink Floyd song.

With configure flags now being sorted, I'm looking at the logs and
seeing:	"-DANOTHER_BRICK_IN_THE -fdata-sections". That makes no sense.
Also the new meson build system did not join the joke. Not fun. Let's
drop it and let this commit serve as recognition of what it was.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/226
2024-11-08 11:31:29 -06:00
Emil Velikov
8ba2e200cd build: alpha sort the compiler flags
Pipe the lot through sort so one can reasonably search, add, edit
without going crazy.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/226
2024-11-08 11:31:29 -06:00
Emil Velikov
ce8a4bbc8e build: remove no longer needed -Wno flags
Nearly all the -Wno flags are not applicable any more - remove them.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/226
2024-11-08 11:31:29 -06:00
Lucas De Marchi
573fc124be ci: Fix debian/ubuntu installation
Make sure we are running in non-interactive mode and that we don't get
blocked on tzdata update.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/235
2024-11-08 11:29:04 -06:00
Tobias Stoeckmann
a55c094d21 depmod: Check fstatat return value
If fstatat fails, do not access the uninitialized variable st.
Instead, filter the file out.

Basically synchronization with libkmod's conf_files_filter_out.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/230
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-07 14:31:20 -06:00
Tobias Stoeckmann
aad7c6973b libkmod: Prevent ouf of boundary access
Do not access memory out of bounds if the first character read by fgets
is NUL. Treat such a character as EOL instead. This is a purely
defensive measure since /proc/modules should normaly not contain such
characters.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/227
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-07 14:29:52 -06:00
Emil Velikov
6bd8c2bc7b libkmod: const struct index_mm as applicable
The index_mm_{search,read,dump}* API does not mutate the index_mm
struct. So let's annotate it as constant.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/224
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-07 13:43:49 -06:00
Emil Velikov
69a512f7d1 libkmod: return bool from lookup_builtin_file()
The callers are interested if the file is within the list of builtins or
not. So change the return type and push the free() down the stack.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/224
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-07 13:43:49 -06:00
Emil Velikov
3489c2d0f4 libkmod: factor out index_{mm_,}search based lookup
Create a simple helper and reuse it instead of duplicating code.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/224
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-07 13:43:49 -06:00
Emil Velikov
cb1b1bbd7b libkmod: inline _idx_empty_str
The compiler already creates an empty string as applicable, drop the
extra variable.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/224
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-07 13:43:49 -06:00
Emil Velikov
d1fe26b145 libkmod: convert index_{,mm_}value to uint32_t ...
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/224
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-07 13:43:49 -06:00
Emil Velikov
e9ef603255 libkmod: pass bool alias_prefix to index_{,mm_}dump()
As seen with previous commit, the way we pass an empty string to
index_{,mm_}dump() is very error prone.

Swap that with a bool, which makes things a lot more obvious.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/224
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-07 13:43:49 -06:00
Emil Velikov
3d3421bce2 libkmod: fix dumps for non-alias indexes
For non-alias indexes prefix is an empty string, where
strbuf_pushchars() returns the number of characters added to the strbuf.

Since those are zero, we end up completely skipping the dump process.

Cc: Tobias Stoeckmann <tobias@stoeckmann.org>
Fixes: 889d02b1 ("libkmod: check strbuf return values")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/224
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-07 13:43:49 -06:00
Tobias Stoeckmann
0930e7b492 libkmod: Validate symbol names in ELF files
Make sure that symbol names in ELF files are actually NUL terminated.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/222
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-07 13:40:36 -06:00
Tobias Stoeckmann
2213612e19 libkmod: Unify crclen calculation in ELF parser
Whenever sizeof(mv->crc) is used, it's called crclen, not offcrc.
Move retrieval of field sizes into its own function.
Prepare this as a cleanup for easier auditing.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/222
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-07 13:40:36 -06:00
Lucas De Marchi
250330e6f5 README: Add release/distro/end-user recommendation
This may be useful for anyone trying a non-debug build and serve as
baseline for distros. Even for developers, when benchmarking kmod, it's
better to run a release-oriented kmod rather than the slow one due to
all debug/sanitizers.

By keeping the -D in the command line rather than in a ini file,
we also guarantee meson shows it in the summary, regardless of
https://github.com/mesonbuild/meson/issues/13865.

Closes: https://github.com/kmod-project/kmod/issues/220
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/221
2024-11-07 11:35:06 -06:00
Lucas De Marchi
18c91d392a README: Let autotools follow the same steps as meson
For meson it's configure & build & install in the same snippet.
Do the same for autotools.

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/221
2024-11-07 11:35:06 -06:00
Emil Velikov
a4b07d98c7 ci: re-enable sanitizers with Fedora 41
We had the sanitizers disabled on Fedora 40, since the shared library
sanitizers comings with clang were not packaged. With Fedora 41 that has
changed, so let's try re-enabling them.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/219
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-07 11:07:41 -06:00
Emil Velikov
c7686797fc scripts/sanitizer-env.sh: support new clang 19 DSO
Seemingly with version 19, the CPU arch was dropped from the DSO name.
Try that and fallback to the old one, as applicable.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/219
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-07 11:07:41 -06:00
Emil Velikov
870aa6fe99 scripts/sanitizer-env.sh: check and warn if OUR_PRELOAD is not a file
As seen with the upcoming clang 19 change, the library name has changed.
Enhance the current test to check if the compiler provided string is a
file and produce a warning with some handy tips when that's not the
case.

v2:
 - convert to heredoc
 - output to stderr

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/219
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-07 11:07:41 -06:00
Emil Velikov
613a21d662 scripts/sanitizer-env.sh: promote unknown compiler to warning/stderr
Should make it more distinguishable, depending on shell and/or CI setup,
from the informational message.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/219
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-07 11:07:41 -06:00
Emil Velikov
34a066b6e3 scripts/sanitizer-env.sh: convert to heredoc
Convert to heredoc and add leading/trailing blank lines so it stands out
from the rest. It makes for cleaner reading experience both of the
script itself and its output.

As suggested by Lucas.

v2:
 - don't escape ", drop spurious instance

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/219
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-07 11:07:41 -06:00
Emil Velikov
2410f11e60 meson: s/modulesi/modules/ typo
Fix the typo in the option description.

Reported-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/225
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-07 10:10:34 -06:00
Emil Velikov
5c3ea2f45d README.md: adjust the optional dependency note
With last commit we've default-enabled a few options. So the optional
dependencies become required now.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/225
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-07 10:10:34 -06:00
Emil Velikov
5b2f86cd08 meson: default enable compression and openssl
The default for the compressions and openssl is based on the autotools
build ones. With the initial goal to make migration as easy as possible
- identical option names, help messages, defaults...

Although a bunch of these have changed already, plus we want builders to
get support for compressed/signed modules out of the box.

So let's flip the defaults - everyone is welcome to adjust those when
calling `meson setup -D foo=bar`.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/225
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-07 10:10:34 -06:00
Tobias Stoeckmann
093285cb6a libkmod: Fix typo in comment
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/223
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-04 07:26:44 -06:00
Emil Velikov
e0a9df3b7a meson: don't escape module_foo in kmod.pc
The kmod.pc file, contains module_signatures and module_compressions
space-separated lists, indicating how kmod is built. For the meson
generated file, any spaces are escaped where the autotools one does not
do that.

Update the meson build to be consistent with the original autotools one
and omit the escaping that we don't want.

Aside: seems like autotools does not escape the directory variables
either, so if the path(s) have any spaces in them pkg-config (pkgconf at
least) produces rubbish, quite rightfully IMHO.

Eg.
  $ cat .../autotools-file.pc
  prefix=/usr
  includedir=${prefix}/include bar
  Cflags: -I${includedir}
  ...
  $ pkg-config --cflags autotools-file.pc
  bar

  $ cat .../meson-file.pc
  prefix=/usr
  includedir=${prefix}/include\ bar
  Cflags: -I${includedir}
  ...
  $ pkg-config --cflags meson-file.pc
  -I/usr/include\ bar

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/217
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-01 10:35:21 -05:00
Emil Velikov
d5c7452c29 meson: align default distconfdir with autotools
Autotools uses $prefix/lib as the default for distconfdir, while meson
$libdir - which is not guaranteed to be the same.

In particular: Debian and derivatives use /usr/lib/$target-triplet as a
$libdir, while still keep the configuration directory as /usr/lib.

Fixes: 370141c1 ("meson: introduce meson, covering libkmod.so")
Reported-by: Marco d'Itri <md@linux.it>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/216
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-01 10:33:37 -05:00
Tobias Stoeckmann
6e10fd50dc libkmod: Properly skip first symbol entry
This fixes a regression introduced while converting pointer to
offset arithmetics.

The for-loop itself starts at 1 already, so reflect this with the
manually performed offset + length calculation right at the start.

Closes: https://github.com/kmod-project/kmod/issues/214
Fixes: 25ab561b ("libkmod: Use ELF offsets more often")
Reported-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/215
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-30 07:59:18 -05:00
Tobias Stoeckmann
4891b4b095 libkmod: Unify kmod_module_new_from_* functions
Return result of kmod_module_new directly in kmod_module_new_from_alias
so this function handles return values like the others.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/211
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-28 21:55:10 -05:00
Tobias Stoeckmann
d090fb3ae5 libkmod: Clean up all dependencies on error path
If kmod_module_parse_depline runs out of memory, it is possible
that not all dependency modules are unlinked.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/211
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-28 21:55:10 -05:00
Tobias Stoeckmann
6ac1bccfe1 libkmod: Clarify function signature
The module_get_dependencies_noref function may modify content of
given kmod_module struct, so clarify this fact.

Actually we would have to adjust kmod API for total clarification,
but let's start with internally used functions first.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/211
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-28 21:55:10 -05:00