Commit Graph

800 Commits

Author SHA1 Message Date
Lucas De Marchi
5706fb7d61 strbuf: Add strbuf_used()
So users don't feel tempted to look at inside the strbuf. Just add a
function for it and proper tests.

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/239
2024-11-17 15:35:13 -06:00
Lucas De Marchi
25f2b2e096 strbuf: Invalidate (only) when stolen
The main for strbuf_steal() to free() on error was to allow the caller
to pass the NULL up the stack with just a return call to
strbuf_steal().

However this is error-prone and surprising that the buffer is still
invalidated on error. Provide an strbuf cleanup attribute that can be
used for the same purpose and make sure that when the string is stolen,
it's set to NULL, so there's no dangling pointer around.

Since we run the  testsuite with AddressSanitizer, a simple test can be
added to make sure the stolen string becomes valid when the attribute is
used.

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/239
2024-11-17 15:35:13 -06:00
Tobias Stoeckmann
ebd0476972 libkmod: Release memory on error paths
Do not override pointers to first list nodes if appending failed,
otherwise it's impossible to release already existing nodes of these
lists afterwards.

Remove the now unused function kmod_list_remove_n_latest as well.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/228
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-15 12:59:45 -06:00
Tobias Stoeckmann
63aec6095b libkmod: Introduce kmod_list_release
Add a macro to reduce amount of explicit while-loops for removal of
nodes and release of their associated data in code base.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/228
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-15 12:59:45 -06:00
Emil Velikov
16ea23b741 libkmod: store common section off/size and use them
Currently, we repeatedly loop over the elf headers looking for five well
known sections. Just do it once in kmod_elf_new() and reuse the data as
needed.

Note that not all sections are guaranteed to be available, so check and
ELFDBG print the ones which are missing.

v2: quit looping when found, ELFDBG print missing sections
v3: match the first section name, use a loop

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/210
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-15 10:03:46 -06:00
Emil Velikov
9099346ce9 libkmod: rename kmod_elf_get_strings()
Rename kmod_elf_get_strings() to kmod_elf_get_modinfo_strings() and fold
the section name within, instead of passing it as an argument.

This aligns better with the other kmod_elf function names and will allow
us to tweak the kmod_elf_get_section() handling with later commit.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/210
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-15 10:03:46 -06:00
Emil Velikov
18567a8eb6 libkmod: stop copying symbol names in kmod_elf_get_dependency_symbols()
Since the caller already copies the strings as needed, we can just
point to the elf data directly.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/210
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-15 10:03:46 -06:00
Emil Velikov
4c74e4dcec libkmod: stop copying symbol names in kmod_elf_get_symbols()
Since the caller already copies the strings as needed, we can just
point to the elf data directly.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/210
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-15 10:03:46 -06:00
Emil Velikov
63e10397b0 libkmod: stop copying symbol names in kmod_elf_get_symbols_symtab()
Since the caller already copies the strings as needed, we can just
point to the elf data directly.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/210
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-15 10:03:46 -06:00
Emil Velikov
e5ef157bd5 libkmod: check for trailing \0 in __ksymtab_strings
As per the documentation (man 5 elf) the section must be null
terminated. Move the check further up and remove the no longer needed
code trying to workaround non-compliant instances.

Note: drop the erroneous +1 in the overflow (malloc size) calculation

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/210
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-15 10:03:46 -06:00
Emil Velikov
069d314f8a libkmod: stop copying symbol names in kmod_elf_get_modversions()
Since the caller already copies the strings as needed, we can just
point to the elf data directly.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/210
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-15 10:03:46 -06:00
Emil Velikov
b5c9f24188 libkmod: const annotate kmod_modversion::symbol
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/210
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-11-15 10:03:46 -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
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
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
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
Tobias Stoeckmann
be728dd347 libkmod: Simplify module dependency parsing
The return value of kmod_module_parse_depline and
module_get_dependencies_noref are never used, and the same is true for
n_dep in struct kmod_module.

Remove them and turn variable n in kmod_module_parse_depline into a
size_t to make sure that it never overflows.

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
a4de36806a libkmod: Fix typo in libkmod.h
It's "within" instead of "with in".

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
ed28efa53b libkmod: Reduce code duplication
If functions exist which cover the exact explicitly written code, use
them instead.

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
daccf4613f libkmod: Use fread_unlocked
This is in sync with read_char, which uses getc_unlocked. This and
previous FILE based index adjustments improved FILE based index dump
performance by 8 %.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/190
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-28 21:50:14 -05:00
Tobias Stoeckmann
0f6d92ad78 libkmod: Add better caching to FILE index
We can use getdelim and reuse buffers by referencing the index_file
instead of just the FILE handle.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/190
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-28 21:50:14 -05:00
Tobias Stoeckmann
899824576d libkmod: Read multiple numbers at once
Reduce the FILE overhead by reading as many bytes as possible at once.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/190
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-28 21:50:14 -05:00
Lucas De Marchi
cb9a656f83 Revert "libkmod: call fnmatch() only as needed"
This reverts commit e79bba6b4a.

This broke alias resolution to more than one module. Example:

	kmod v33:
	$ modprobe -R char-major-116-1
	snd
	snd_seq

	e79bba6b4a:
	$ ./modprobe -R char-major-116-1
	snd

Closes: https://github.com/kmod-project/kmod/issues/207
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/208
2024-10-24 10:08:01 -05:00
Tobias Stoeckmann
1fa0b27acb libkmod: Read mm index node content on demand
Many values are never needed, so only parse them on demand. Also keep
pointers into memory-mapped area without copying data into dynamically
sized structs, which allows nodes to be kept on stack.

Improves performance of `modprobe -c` by around 3 %.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/201
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-23 23:27:01 -05:00
Tobias Stoeckmann
cab7ddd5dd libkmod: Simplify index search functions
Remove arguments with fixed values. Also increment char pointers instead
of working with addresses of indices for easier readability.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/201
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-23 23:27:01 -05:00
Tobias Stoeckmann
b3a7664fea libkmod: Fix typos
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/201
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-23 23:27:01 -05:00
Tobias Stoeckmann
33248df9ea libkmod: Const annotate read_*_mm API
Clarify that we never intend to modify the memory-mapped content.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/201
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-23 23:27:01 -05:00
Emil Velikov
1e4cd85c0b docs: annotate the deprecated API
The kmod_module_get_filtered_blacklist() was deprecated since kmod v6 in
favour of kmod_module_apply_filter().

Add the decoration so gtk-doc includes it in the generated html and also
add a designated index.

It seem that gtk-doc insists on having deprecation guards, so not it
prints an extra warning like:

  warning: XXX is deprecated in the inline comments, but no deprecation
  guards were found around the declaration. (See the --deprecated-guards
  option for gtkdoc-scan.)

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/200
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-23 23:19:11 -05:00
Emil Velikov
af27216996 docs: add per-version index sections
With the introduction of the "Since: XX" tags, gtk-doc has been
helpfully reminding us that the per-version index isn't referenced
anywhere.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/200
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-23 23:19:11 -05:00
Tobias Stoeckmann
33e3d24cdb libkmod: Prevent OOB with huge amount of symbols
On 32 bit systems it's possible to overflow the final calculation of
required memory for symbols retrieved from __ksymtab_strings.

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/198
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-22 12:23:42 -05:00
Tobias Stoeckmann
5ebbde9380 libkmod: Adjust style
Add a blank between variable declaration and function calls.

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/196
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-22 12:02:56 -05:00
Tobias Stoeckmann
ff17adf210 libkmod: Use correct format specifiers
Use correct format specifiers for size_t variables.

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/196
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-22 12:02:56 -05:00
Tobias Stoeckmann
1319ac5348 libkmod: Access correct array
The contents of s and strings are identical at this point, but iterate
over the correct variable nonetheless.

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/196
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-22 12:02:56 -05:00
Tobias Stoeckmann
bb0c280181 libkmod: Simplify size checks
An empty section is very unlikely, so reorder code to account for it.

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/196
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-22 12:02:56 -05:00
Tobias Stoeckmann
6d3aa4ed08 libkmod: Remove elf_find_section
The function's purpose can be merged into elf_get_section. Reduces
amount of duplicated code.

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/196
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-10-22 12:02:56 -05:00