Emil Velikov [Thu, 3 Oct 2024 16:02:45 +0000 (17:02 +0100)]
ci: directly use archlinux:multilib-devel container
There was some recent snafu which meant the container wasn't available.
With that resolved, we can drop our hack and use the correct container
directly.
Emil Velikov [Thu, 3 Oct 2024 16:02:45 +0000 (17:02 +0100)]
libkmod: silence autological compare warning
Clang will detect that the enum cannot be zero, thus triggering a
warning. Since this is an external (public API) function, the end-user
can provide any input so we want to keep the check.
Note: include the pragmas in a if defined(__clang__) guard, otherwise
we'll trigger -Wunknown_pragma which will become an error in CI and
developer builds.
Emil Velikov [Thu, 3 Oct 2024 16:02:45 +0000 (17:02 +0100)]
tools/lsmod: initialize use_syslog
Initialize the variable, otherwise we'll get (random) stack value if the
user hasn't provided --syslog. Reported by scan-build.
Fixes: 6313d40d ("tools/lsmod: add basic opts like rmmod") Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Link: https://github.com/kmod-project/kmod/pull/172 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Emil Velikov [Thu, 3 Oct 2024 16:02:45 +0000 (17:02 +0100)]
tools/rmmod: initialize use_syslog
Initialize the variable, otherwise we'll get (random) stack value if the
user hasn't provided --syslog. Reported by scan-build.
Fixes: 24fe68dc ("tools/rmmod: make opt variables non-global") Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Link: https://github.com/kmod-project/kmod/pull/172 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Emil Velikov [Thu, 3 Oct 2024 16:02:45 +0000 (17:02 +0100)]
tools/insmod: initialize use_syslog
Initialize the variable, otherwise we'll get (random) stack value if the
user hasn't provided --syslog. Reported by scan-build.
Fixes: ca8f04e8 ("tools/insmod: add syslog and verbose options") Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Link: https://github.com/kmod-project/kmod/pull/172 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Emil Velikov [Thu, 3 Oct 2024 16:02:45 +0000 (17:02 +0100)]
shared: add missing stddef.h include
Required for size_t, reported by clang-tidy.
Fixes: 38943b20 ("shared: use size_t for strbuf") Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Link: https://github.com/kmod-project/kmod/pull/172 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Emil Velikov [Thu, 3 Oct 2024 15:46:00 +0000 (16:46 +0100)]
man: list short/long opt on same line
With earlier commit, I attempted to keep them on separate lines for
somewhat dubious reasons. In practise that didn't work and they stayed
on the same line, while also dropping the separating comma.
Looking back, it would be better to fix the vim manpager mode issues
rather than mask it. Mea culpa
Reference: https://lore.kernel.org/linux-modules/ZvknyLKvQeBo16n9@meinfjell.helgefjelltest.de Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Link: https://github.com/kmod-project/kmod/pull/164 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
If value of "first" is negative, then a broken index can trigger a stack
based buffer overflow, because child_count could become larger than
INDEX_CHILDMAX.
Before kmod_module_new_from_path creates a module with kmod_module_new,
it checks with kmod_pool_get_module if a module with given name already
exists.
This check can be removed, because kmod_module_new does the same. If the
module already existed, the same checks are performed as in current code
for the "if (m != NULL)" case. If it did not exist yet, m->path is NULL
and the first if-block is entered.
And since kmod_module_new takes care of incrementing the reference
counter, the explicit call of kmod_module_ref can be removed from
kmod_module_new_from_path as well.
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/168 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
It is meant as a backing buffer for scratch buffer. Do not use it
directly when constructing strings.
Co-authored-by: Lucas De Marchi <lucas.de.marchi@gmail.com> Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org> Link: https://github.com/kmod-project/kmod/pull/166 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Accessing the backing "alias" char buffer directly works only as long as
all symbols are smaller than 1024, because otherwise the scratch buffer
allocates memory and the addresses do not match anymore.
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/152 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The strbuf functions may fail, so handle errors. Make especially sure
that push and pop operations stay in sync.
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/152 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The unsigned int data type might be too small on 64 bit systems and
when encountering huge and illegal index files.
Since lengths are retrieved from strbuf structs, this also keeps
the data type lengths in sync.
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/152 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The code does not support 65535 or more modules. Since this value is
probably never reached, add a proper check after array building and
do not rely solely on an assert later in code path.
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/158 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
depmod: Support modules.order with duplicate lines
If the same line exists multiple times in modules.order, consider only
the first, since this is the earliest position requested.
This also makes sure that index iterator never turns positive or would
ever trigger a signed integer 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/158 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The current code iterates through modules.order twice. First, it
figures out how many lines exist. Then it iterates again to make
sure that the first line has the lowest sort index, then ascending.
Negative values make sure that the previously assigned positive
values will be larger, i.e. modules in modules.order take precedence,
then modules found in file system which were not listed in
modules.order.
This can be simplified by setting the initial sort index value to
the lowest possible value needed, i.e. -depmod->modules.count.
With this value, it is possible to iterate only once.
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/158 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
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/158 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
No need to clear newly allocated memory if source is copied into
destination directly.
Simplify code by using memdup from shared.
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/158 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
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/158 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Emil Velikov [Sat, 28 Sep 2024 13:12:26 +0000 (14:12 +0100)]
ci: enable sanitizers in the meson build
... to prevent a range of issues creeping in.
Currently ASAN reports an ordering issue that we need to explicitly
disable. Thus the sanitizers are only enabled in CI and not for all
developer builds (aka build-dev.ini).
Seemingly musl lacks the sanitizers, so we don't enable it on Alpine.
testsuite: Fix test-weakdep with autoconf defaults
If ./configure is run without any further options, then /usr/etc
is used as SYSCONFDIR, which breaks test-weakdep, because the
/etc path is hardcoded in it.
Use SYSCONFDIR to reflect the actual rootfs setup.
If a file name does not end with ".ko", there is no need to call fstat.
Since common use cases are like "modinfo modname", the string check
should come first to save a tiny amount of system time.
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/154 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
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/156 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Fix memory leak on error path introduced with read_u32 error checks.
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/153 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
On 32 bit systems it is possible to trigger an out of boundary write
with excessively huge ELF files.
The calculation of required memory for char pointer vector and strings
might overflow, leading to an allocation which is too small. Subsequent
memcpy leads to an out of boundary write.
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/149 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
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/148 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
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/148 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Emil Velikov [Sun, 8 Sep 2024 10:38:13 +0000 (11:38 +0100)]
ci: add clang-format action
To keep the style consistent.
Closes: https://github.com/kmod-project/kmod/issues/88 Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Link: https://github.com/kmod-project/kmod/pull/118 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
ASAN incorrectly reports this as unaligned access if compiler
optimizes code. Since ASAN support is valued higher than this
kind of optimization, just copy these few bytes into a stack
variable and avoid false positives in tests.
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/147 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
If an excessively large root directory is supplied, subsequent
operations might process unexpected parts in file system.
Inform user that supplied directory paths are too long and stop
program execution.
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/72 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Remove arbitrary limits due to file sizes (INTPR_MAX check). Reduce
amount of system calls by up to 90 % utilizing stream functions.
Also make sure that no TOCTOU could ever happen by not iterating
through the file twice: First to figure out amount of strings, then
parsing them. If the file changes in between, this can lead to
memory corruption.
Even though more memory allocations might occur due to strbuf usage,
performance generally increased by heavy reduction of system 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/136 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The modinfo command can show information about builtin modules. Make
sure that it functions correctly.
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/136 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Emil Velikov [Thu, 19 Sep 2024 14:50:21 +0000 (15:50 +0100)]
testsuite: sort modnames only, if available
In some tests we expect zero modules to be loaded. In those cases, skip
the sorting - qsort is annotated as non-null(1,2) so we shouldn't
provide null as expected/loaded modules.
Emil Velikov [Sun, 22 Sep 2024 11:52:42 +0000 (12:52 +0100)]
ci: add SPDX copyright/license identifiers
To make it clear and explicit on the topic. Inspired by me reusing some
of those for usbutils and reuse-tool [1] flagging the lack of proper
attribution.
Emil Velikov [Wed, 18 Sep 2024 16:32:31 +0000 (17:32 +0100)]
libkmod: remove __secure_getenv handling
The build-time checking for __secure_getenv was dropped earlier, yet I
forgot to remove the actual users :facepalm:
Fixes: 9dc54a3 ("build: stop checking for __secure_getenv") Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Link: https://github.com/kmod-project/kmod/pull/139 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Emil Velikov [Wed, 18 Sep 2024 15:49:08 +0000 (16:49 +0100)]
tools/insmod: add --force longopt and document it
As of the initial import to git, the option was silently ignored.
Shortly afterwards, functionality was reinstated lacking a longopt and
any documentation.
As per insmod(8) for most use-cases you'd want to use modprobe(8).
Although since the option is available and we have an equivalent in
rmmod(8) having it documented and consistent triumphs.
Emil Velikov [Wed, 18 Sep 2024 15:49:08 +0000 (16:49 +0100)]
tools/insmod: remove unused -p -s shortopts
These have been around since the import to git, doing nothing. There are
no users that I can see, the manual page does not list them and the
shell completions (fish and bash lack any for insmod, zsh has one) don't
suggest it either.
Emil Velikov [Wed, 18 Sep 2024 15:49:08 +0000 (16:49 +0100)]
tools/rmmod: tweak --force help message
Drop the kernel configuration details - the CONFIG toggle name is more
useful (since you can see it in /proc/config.*) and generally the part
is better suited for the manual page.
Move DANGEROUS at the front, so it's obvious from the start
Emil Velikov [Wed, 18 Sep 2024 15:49:08 +0000 (16:49 +0100)]
tools/rmmod: remove unused -w shortopt
The (long)option and handling was removed some 10 years ago, yet the
shortopt remained... oops
Fixes: a4bd144 ("Remove "rmmod -w" documentation and getopt entry") Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Link: https://github.com/kmod-project/kmod/pull/138 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Emil Velikov [Wed, 18 Sep 2024 15:49:08 +0000 (16:49 +0100)]
tools: add kmod_version() helper
Add a trivial helper that prints the version + features combo. I will be
adding another instance of those, so I'm aiming to keep the boilerplate
code to a minimum.
Apply same logic as in delete_module.c, i.e. pass a reference to a
pointer instead of the pointer value, otherwise we cannot update
the linked list and added entries are lost.
Spotted with ASAN while running testsuite.
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/141 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
If an index file with INDEX_NODE_CHILDS flag contains illegal first
and last markers for children, it is possible to trigger an out of
boundary write.
Make sure that first value is not larger than last value while reading
index files.
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/126 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Emil Velikov [Tue, 17 Sep 2024 09:49:38 +0000 (10:49 +0100)]
shared: remove no longer used NOFAIL() macro
Closes: https://github.com/kmod-project/kmod/issues/60 Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Link: https://github.com/kmod-project/kmod/pull/135 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Since off_t can (and most likely will) be 64 bit on 32 bit systems,
check its actual value before casting it to 32 bit size_t.
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/96 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
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/123 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Forward errors to callers instead of relying on unimplemented macro.
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/123 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
If read_char fails, stop operations and return an error 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/123 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The fatal macro was never implemented. Its only user, libkmod-index,
should propagate error condition through errno as good as possible.
Other logging mechanisms are not available without adjusting API
because context is missing.
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/123 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
If read_long fails, forward error up to caller. Also perform proper
fread return value check.
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/123 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
The return value is currently not needed. In prepration for subsequent
commits, use the return value to report if errors occurred or not.
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/123 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Emil Velikov [Sun, 15 Sep 2024 00:40:37 +0000 (01:40 +0100)]
build: stop checking for __secure_getenv
Currently we check for both __secure_getenv and secure_getenv. The
former was introduced with glibc 2.2.5 as internal(?) API, while the
has been part of glibc 2.17, circa 2012.
Drop the former check. It may have been required over 10 years ago, but
not any more.
Emil Velikov [Sun, 15 Sep 2024 00:40:14 +0000 (01:40 +0100)]
build: check for __xstat declarations
Currently we check the function is resolved at link time. Although what
we really care is if the headers are silently transposing any of our stat
calls to __xstat{,64}. If so, we'd want to wrap the latter functions.
As the now-removed comment says, glibc 2.33 was the first release to no
longer have static inline wrappers that do the transposition. See the
glibc commit 8ed005daf0ab ("Remove stat wrapper functions, move them to
exported symbols") for more details.
So change the checking to check_decl/has_header_symbol and keep them for
distributions with older glibc.
NOTE: to summarise/contrast this wrt the previous open64, etc
- here: we had inline wrappers and declarations (as below)
- others: no inline wrappers and optionally declarations
Emil Velikov [Sun, 15 Sep 2024 18:04:19 +0000 (19:04 +0100)]
meson: use has_header_symbol for checking declarations
Currently we use has_function, which will construct local declaration
and see if the program links successfully. What we're really interested
is if the referenced header has a declaration of the respective symbol.
Emil Velikov [Sun, 15 Sep 2024 10:03:00 +0000 (11:03 +0100)]
build: check properly for __stat64_time64
Having learned from prior LFS64 experience the glibc developers have
implemented stat in (albeit varying but) neater way:
- declaration with asm linkage to __stat64_time64
- or, `#define stat __stat64_time64`
- or, `#define stat stat64; #define stat64 __stat64_time64`
In all cases __stat64_time64 lacks an explicit declaration, unlike
open64, stat64, fopen64 mentioned earlier.
Since we lack declaration, we have no other option but to check if a
program with reference to __stat64_time64 can link, so we use the
check/has function.
For more details glibc commit aa03f722f3 ("linux: Add {f}stat{at} y2038
support") added internal.
Emil Velikov [Sun, 15 Sep 2024 10:03:00 +0000 (11:03 +0100)]
testsuite/path: s/__stat64_t64/void/
The exact struct varies across the build-options, but in practise is
never __stat64_t64 - this is the internal name used within glibc.
When the fstat declaration with __fstat64_time64 asm linkage is used, we
have "struct stat". Whenever the `#define stat __stat64_time64` kicks
in, both function and struct get redefined/renamed.
Since we don't care about it (apart from the pointer part) just use void.
For more details glibc commit aa03f722f3 ("linux: Add {f}stat{at} y2038
support") added internal.
Emil Velikov [Sun, 15 Sep 2024 09:11:49 +0000 (10:11 +0100)]
build: check for open64, stat64 and fopen64
... and use behind the respective ifdef HAVE_FOO guards instead of the
HAVE_DECL___GLIBC__ currently.
Since day one, glibc has declarations for the functions, which was
forwarding the normal functions to them, via asm linkage, et al.
Aka `extern int open(....) asm_linkage("open64").
In addition, a lot of libraries have grown to depend on the declarations
being available and functions being statically exposed via libc.so.
Whereas musl pre 1.2.4 (circa 2023) have exposed the symbols
statically, without a declaration for well over a decade. Newer musl,
no longer expose the symbol in their runtime but have retained the
define trick, stating it will be removed in the future.
Looking at the bionic front things are somewhat similar. Newer bionic
(circa 2019) have a declaration and an inline wrapper open64 function
forwarding to open. Throughout 2019, open64 did forward to misc other
internal functions thought.
Older pre 2019 bionic had a declaration alongside plug exposing the
symbol statically in their C runtime.... since 2014. Not sure what they
did prior to 2014, it's a target out of scope for us.
Considering the above, the most robust approach is to do a check/has
function checking.
With that, we no longer need the __GLIBC__ guard for the respective
functions.
Emil Velikov [Sat, 14 Sep 2024 14:08:59 +0000 (15:08 +0100)]
testsuite: remove access() sub-test
Our test does access + stat, where stat is sufficient. In addition, the
kmod codebase never used access (afaict), so we're safe to remove the
access() part.
Emil Velikov [Sat, 14 Sep 2024 13:57:44 +0000 (14:57 +0100)]
testsuite: remove *lstat* wrappers
The majority of these were initially introduced with commit 123e827
("testsuite preload: Factorize into macros, add more stat and open
variants").
The commit itself was meant to refactor existing wrappers and add new
_xstat (aka stat) variants. The lstat variants were never used in kmod
directly nor indirectly via header macros.
The rest were added to mimic the original, without much testing it
seems.
They are all dead code - remove them.
In theory one could have a macro/helper that calls `lstat` for `stat`
itself, although that isn't a practical solution for a few reasons.
The functionality across the two varies, where if the path provided is
a symlink `stat` follows it, while `lstat` gets the details for the link
itself. To fix this, the wrapper would need second syscall to resolve
the symlink, which will cause notable performance regression wrt using
using the `stat`/`stat64` syscall alone.
Emil Velikov [Mon, 16 Sep 2024 22:39:23 +0000 (23:39 +0100)]
CONTRIBUTING.md: mention license and SPDX
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Link: https://github.com/kmod-project/kmod/pull/134
[ Mention LGPL is preferred, even for tools/ ] Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>