[packages/kmod] Rel 3. Backport alias overflow, get_sections and backoff loop fixes
arekm
arekm at pld-linux.org
Thu Oct 29 08:38:46 CET 2026
commit 3f45a442f99ce69557501ccfdbedf66203382ce7
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Thu Oct 29 00:54:48 2026 +0100
Rel 3. Backport alias overflow, get_sections and backoff loop fixes
alias-normalize-overflow.patch | 37 ++++++++++++++++++++++++++++++
backoff-endless-loop.patch | 51 +++++++++++++++++++++++++++++++++++++++++
get-sections-free-list.patch | 52 ++++++++++++++++++++++++++++++++++++++++++
kmod.spec | 12 ++++++++--
4 files changed, 150 insertions(+), 2 deletions(-)
---
diff --git a/kmod.spec b/kmod.spec
index 03c844b..7a590d5 100644
--- a/kmod.spec
+++ b/kmod.spec
@@ -13,7 +13,7 @@ Summary: Linux kernel module handling
Summary(pl.UTF-8): Obsługa modułów jądra Linuksa
Name: kmod
Version: 34.2
-Release: 2
+Release: 3
License: GPL v2+
Group: Applications/System
Source0: https://www.kernel.org/pub/linux/utils/kernel/kmod/%{name}-%{version}.tar.xz
@@ -23,6 +23,12 @@ Source2: %{name}-usb
Patch0: %{name}-modprobe.d-kver.patch
Patch1: %{name}-depmod.d-kver.patch
Patch2: xz-in-kernel-decompr-compat.patch
+# https://github.com/kmod-project/kmod/commit/d236920b20fd70a139f8af2ff6f5c18d830be491
+Patch3: alias-normalize-overflow.patch
+# https://github.com/kmod-project/kmod/commit/0e72cc59c956b78fe12172cec7bd14d0f09ad651
+Patch4: get-sections-free-list.patch
+# https://github.com/kmod-project/kmod/commit/f14f2603820e46b1946d8f96eee10c99690aea82
+Patch5: backoff-endless-loop.patch
URL: https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git
BuildRequires: autoconf >= 2.64
BuildRequires: automake >= 1:1.11
@@ -117,6 +123,9 @@ Pliki nagłówkowe biblioteki %{name}.
%patch -P 0 -p1
%patch -P 1 -p1
%patch -P 2 -p1
+%patch -P 3 -p1
+%patch -P 4 -p1
+%patch -P 5 -p1
%build
%{__libtoolize}
@@ -127,7 +136,6 @@ Pliki nagłówkowe biblioteki %{name}.
%configure \
--disable-silent-rules \
%{?with_apidocs:--enable-gtk-doc} \
- %{?with_python2:--enable-python} \
--with-distconfdir=/%{_lib} \
--with-bashcompletiondir=%{bash_compdir} \
--with-fishcompletiondir=%{fish_compdir} \
diff --git a/alias-normalize-overflow.patch b/alias-normalize-overflow.patch
new file mode 100644
index 0000000..2f059e5
--- /dev/null
+++ b/alias-normalize-overflow.patch
@@ -0,0 +1,37 @@
+From d236920b20fd70a139f8af2ff6f5c18d830be491 Mon Sep 17 00:00:00 2001
+From: Anton Moryakov <ant.v.moryakov at gmail.com>
+Date: Tue, 10 Mar 2026 19:07:15 +0300
+Subject: [PATCH] shared: util.c: fix buffer overflow in alias_normalize()
+
+The while-loop inside the '[' case of alias_normalize() increments the
+index 'i' without checking against PATH_MAX bounds. If the input string
+contains an opening '[' followed by many characters without a closing ']',
+the index can exceed PATH_MAX-1, causing a buffer overflow when writing
+to buf[i].
+
+Signed-off-by: Anton Moryakov <ant.v.moryakov at gmail.com>
+Reviewed-by: Emil Velikov <emil.l.velikov at gmail.com>
+Link: https://github.com/kmod-project/kmod/pull/431
+Signed-off-by: Lucas De Marchi <demarchi at kernel.org>
+---
+ shared/util.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/shared/util.c b/shared/util.c
+index 4e2736ddb..d4b025b7e 100644
+--- a/shared/util.c
++++ b/shared/util.c
+@@ -79,10 +79,12 @@ int alias_normalize(const char *alias, char buf[static PATH_MAX], size_t *len)
+ case ']':
+ return -EINVAL;
+ case '[':
+- while (alias[i] != ']' && alias[i] != '\0') {
++ while (i < PATH_MAX - 1 && alias[i] != ']' && alias[i] != '\0') {
+ buf[i] = alias[i];
+ i++;
+ }
++ if (i >= PATH_MAX - 1)
++ return -EINVAL;
+
+ if (alias[i] != ']')
+ return -EINVAL;
diff --git a/backoff-endless-loop.patch b/backoff-endless-loop.patch
new file mode 100644
index 0000000..fb363bc
--- /dev/null
+++ b/backoff-endless-loop.patch
@@ -0,0 +1,51 @@
+From f14f2603820e46b1946d8f96eee10c99690aea82 Mon Sep 17 00:00:00 2001
+From: Tobias Stoeckmann <tobias at stoeckmann.org>
+Date: Sun, 29 Jun 2025 13:13:34 +0200
+Subject: [PATCH] util: fix endless loop in get_backoff_delta_msec
+
+If current time t is already past tend, the while loop in
+get_backoff_delta_msec never ends.
+
+Signed-off-by: Tobias Stoeckmann <tobias at stoeckmann.org>
+Link: https://github.com/kmod-project/kmod/pull/377
+Signed-off-by: Lucas De Marchi <lucas.de.marchi at gmail.com>
+---
+ shared/util.c | 23 +++++++++++++++--------
+ 1 file changed, 15 insertions(+), 8 deletions(-)
+
+diff --git a/shared/util.c b/shared/util.c
+index 2ffe56471..3d5d179bb 100644
+--- a/shared/util.c
++++ b/shared/util.c
+@@ -540,16 +540,23 @@ unsigned long long get_backoff_delta_msec(unsigned long long tend,
+
+ t = now_msec();
+
+- if (!*delta)
+- *delta = 1;
+- else
+- *delta <<= 1;
++ if (tend <= t) {
++ /* Timeout already reached */
++ *delta = 0;
++ } else {
++ const unsigned long long limit = tend - t;
++
++ if (!*delta)
++ *delta = 1;
++ else
++ *delta <<= 1;
+
+- while (t + *delta > tend)
+- *delta >>= 1;
++ while (*delta > limit)
++ *delta >>= 1;
+
+- if (!*delta && tend > t)
+- *delta = tend - t;
++ if (!*delta)
++ *delta = limit;
++ }
+
+ return t + *delta;
+ }
diff --git a/get-sections-free-list.patch b/get-sections-free-list.patch
new file mode 100644
index 0000000..08a47db
--- /dev/null
+++ b/get-sections-free-list.patch
@@ -0,0 +1,52 @@
+From 0e72cc59c956b78fe12172cec7bd14d0f09ad651 Mon Sep 17 00:00:00 2001
+From: Syed Labeeq Sajid Bukhari <syedlabeeq at gmail.com>
+Date: Mon, 12 Oct 2026 15:16:10 +0500
+Subject: [PATCH] libkmod: fix type confusion in kmod_module_get_sections()
+ error path
+
+The fail: path of kmod_module_get_sections() releases the partially
+built list with kmod_module_unref_list(), but the list elements are
+struct kmod_module_section, not struct kmod_module.
+
+kmod_module_unref() on a section object first reads and decrements
+mod->refcount, which sits at offset 80 of struct kmod_module, while a
+section allocation is only 8 + strlen(name) + 1 bytes (~17-25 bytes)
+-- an out-of-bounds read+write on the heap. If the decremented value
+happens to be <= 0, execution continues with mod->ctx aliasing
+section->address and mod->path/mod->hashkey aliasing the section name
+bytes, leading to wild dereferences and frees of semi-controlled
+pointers (kmod_pool_del_module, kmod_module_unref_list(mod->dep),
+free(mod->path)).
+
+The bug is reachable through the public API kmod_module_get_sections()
+(used by modinfo) whenever the loop over /sys/module/<mod>/sections/
+fails mid-iteration after at least one section was appended: an
+openat/read failure (e.g. module unload race or an unreadable section
+file) or a malloc failure.
+
+The function's own API documentation in libkmod.h states the returned
+list must be freed with kmod_module_section_free_list(); the error
+path is the only place that violates this.
+
+Fix it by freeing the list with kmod_module_section_free_list(), as
+the success path and the API contract already do.
+
+Link: https://github.com/kmod-project/kmod/pull/467
+Signed-off-by: Lucas De Marchi <demarchi at kernel.org>
+---
+ libkmod/libkmod-module.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
+index 2248acf2..17dce973 100644
+--- a/libkmod/libkmod-module.c
++++ b/libkmod/libkmod-module.c
+@@ -1748,7 +1748,7 @@ KMOD_EXPORT struct kmod_list *kmod_module_get_sections(const struct kmod_module
+
+ fail:
+ closedir(d);
+- kmod_module_unref_list(list);
++ kmod_module_section_free_list(list);
+ return NULL;
+ }
+
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/kmod.git/commitdiff/3f45a442f99ce69557501ccfdbedf66203382ce7
More information about the pld-cvs-commit
mailing list