Jan Engelhardt 2014-06-24 13:19:36 +00:00 committed by Git OBS Bridge
parent 4d0c3cc817
commit 8797ee9329
7 changed files with 36 additions and 244 deletions

View File

@ -1,214 +0,0 @@
From c48b269d64e4c2e23194f0a7c20d27e7727cdf3d Mon Sep 17 00:00:00 2001
From: Lucas De Marchi <lucas.demarchi@intel.com>
Date: Fri, 9 May 2014 08:22:02 -0300
Subject: [PATCH] depmod: Make dependency loops be fatal
Since the beginning depmod just warned about dependency loops and upon
creation of modules.dep{,.bin} it skipped the modules that were part of
a loop. However just skipping the modules may come as a surprise to
kernel module developers: they will need to try to load the module (or
to pay attention to the log messages) to notice thavt the module has not
been put in the index. Also, differently from module-init-tools we were
not skipping modules that depend on modules with dependency loops,
leading to a segfault in depmod.
So this is a summary of the change in behavior with this patch:
Loop 1)
A -> B -> C -
^ |
'------------
Before:
depmod: WARNING: found 3 modules in dependency cycles!
depmod: WARNING: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleB.ko in dependency cycle!
depmod: WARNING: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleC.ko in dependency cycle!
depmod: WARNING: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleA.ko in dependency cycle!
return code: 0
After:
depmod: ERROR: Found 3 modules in dependency cycles!
depmod: ERROR: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleB.ko in dependency cycle!
depmod: ERROR: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleC.ko in dependency cycle!
depmod: ERROR: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleA.ko in dependency cycle!
return code: 2
Loop 2)
A -> B -> C -
^ |
'-------
Before:
depmod: WARNING: found 2 modules in dependency cycles!
depmod: WARNING: /tmp/test-kmod//lib/modules/3.14.2-1-ARCH/kernel/moduleB.ko in dependency cycle!
depmod: WARNING: /tmp/test-kmod//lib/modules/3.14.2-1-ARCH/kernel/moduleC.ko in dependency cycle!
Segmentation fault (core dumped)
After:
depmod: ERROR: Found 2 modules in dependency cycles!
depmod: ERROR: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleB.ko in dependency cycle!
depmod: ERROR: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleC.ko in dependency cycle!
return code: 2
The segfault above could be fixed, but let's just fail everything
because dependency cycles should be fixed in the modules rather than
just be skipped in the index.
---
tools/depmod.c | 55 +++++++++----------------------------------------------
1 file changed, 9 insertions(+), 46 deletions(-)
diff --git a/tools/depmod.c b/tools/depmod.c
index 1aedaaf..7ac1e26 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -927,7 +927,6 @@ struct mod {
int dep_sort_idx; /* topological sort index */
uint16_t idx; /* index in depmod->modules.array */
uint16_t users; /* how many modules depend on this one */
- uint8_t dep_loop : 1;
char modname[];
};
@@ -944,7 +943,6 @@ struct depmod {
struct hash *modules_by_uncrelpath;
struct hash *modules_by_name;
struct hash *symbols;
- unsigned int dep_loops;
};
static void mod_free(struct mod *mod)
@@ -1337,12 +1335,6 @@ static int depmod_modules_search(struct depmod *depmod)
static int mod_cmp(const void *pa, const void *pb) {
const struct mod *a = *(const struct mod **)pa;
const struct mod *b = *(const struct mod **)pb;
- if (a->dep_loop == b->dep_loop)
- return a->sort_idx - b->sort_idx;
- else if (a->dep_loop)
- return 1;
- else if (b->dep_loop)
- return -1;
return a->sort_idx - b->sort_idx;
}
@@ -1566,12 +1558,6 @@ static int dep_cmp(const void *pa, const void *pb)
{
const struct mod *a = *(const struct mod **)pa;
const struct mod *b = *(const struct mod **)pb;
- if (a->dep_loop == b->dep_loop)
- return a->dep_sort_idx - b->dep_sort_idx;
- else if (a->dep_loop)
- return 1;
- else if (b->dep_loop)
- return -1;
return a->dep_sort_idx - b->dep_sort_idx;
}
@@ -1592,6 +1578,7 @@ static int depmod_calculate_dependencies(struct depmod *depmod)
const struct mod **itrm;
uint16_t *users, *roots, *sorted;
uint16_t i, n_roots = 0, n_sorted = 0, n_mods = depmod->modules.count;
+ int ret = 0;
users = malloc(sizeof(uint16_t) * n_mods * 3);
if (users == NULL)
@@ -1640,27 +1627,26 @@ static int depmod_calculate_dependencies(struct depmod *depmod)
}
if (n_sorted < n_mods) {
- WRN("found %u modules in dependency cycles!\n",
+ ERR("Found %u modules in dependency cycles!\n",
n_mods - n_sorted);
+ ret = -EINVAL;
for (i = 0; i < n_mods; i++) {
struct mod *m;
if (users[i] == 0)
continue;
m = depmod->modules.array[i];
- WRN("%s in dependency cycle!\n", m->path);
- m->dep_loop = 1;
- m->dep_sort_idx = INT32_MAX;
- depmod->dep_loops++;
+ ERR("%s in dependency cycle!\n", m->path);
}
+ goto exit;
}
depmod_sort_dependencies(depmod);
- DBG("calculated dependencies and ordering (%u loops, %hu modules)\n",
- depmod->dep_loops, n_mods);
+ DBG("calculated dependencies and ordering (%hu modules)\n", n_mods);
+exit:
free(users);
- return 0;
+ return ret;
}
static int depmod_load(struct depmod *depmod)
@@ -1761,11 +1747,6 @@ static int output_deps(struct depmod *depmod, FILE *out)
const char *p = mod_get_compressed_path(mod);
size_t j, n_deps;
- if (mod->dep_loop) {
- DBG("Ignored %s due dependency loops\n", p);
- continue;
- }
-
fprintf(out, "%s:", p);
if (mod->deps.count == 0)
@@ -1779,12 +1760,6 @@ static int output_deps(struct depmod *depmod, FILE *out)
for (j = 0; j < n_deps; j++) {
const struct mod *d = deps[j];
- if (d->dep_loop) {
- DBG("Ignored %s (dependency of %s) "
- "due dependency loops\n",
- mod_get_compressed_path(d), p);
- continue;
- }
fprintf(out, " %s", mod_get_compressed_path(d));
}
free(deps);
@@ -1814,11 +1789,6 @@ static int output_deps_bin(struct depmod *depmod, FILE *out)
size_t j, n_deps, linepos, linelen, slen;
int duplicate;
- if (mod->dep_loop) {
- DBG("Ignored %s due dependency loops\n", p);
- continue;
- }
-
deps = mod_get_all_sorted_dependencies(mod, &n_deps);
if (deps == NULL && n_deps > 0) {
ERR("could not get all sorted dependencies of %s\n", p);
@@ -1828,12 +1798,6 @@ static int output_deps_bin(struct depmod *depmod, FILE *out)
linelen = strlen(p) + 1;
for (j = 0; j < n_deps; j++) {
const struct mod *d = deps[j];
- if (d->dep_loop) {
- DBG("Ignored %s (dependency of %s) "
- "due dependency loops\n",
- mod_get_compressed_path(d), p);
- continue;
- }
linelen += 1 + strlen(mod_get_compressed_path(d));
}
@@ -1854,8 +1818,7 @@ static int output_deps_bin(struct depmod *depmod, FILE *out)
for (j = 0; j < n_deps; j++) {
const struct mod *d = deps[j];
const char *dp;
- if (d->dep_loop)
- continue;
+
line[linepos] = ' ';
linepos++;
--
1.8.1.4

View File

@ -1,17 +0,0 @@
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
iQIcBAABAgAGBQJTQb7hAAoJEJuipaYwy+pTGGUQAJK2Bfd3RtANK9+4s3AeXvGk
xCStqGHEjerf4ecDPMsSAUaNg6ADsGNPiQHDfg3y6wfp15+kmX+JoQPFWyghrIXf
6x/OMN3ilPM2cfqJayacDbtNwTaCOY0JLokLpI0nR5iItdi1u6D++FnAh2UDU3C6
SLOmsZeTYaUZDZwlte0ZERITxaTgAhjoxD7QiKk54KlwTBOK24JSLV/oxmMrUkkH
YB0JQ6vMuJEiHXFZLlJX+hmwElgw0dcB7H2ywVGugGhC+i1so/z1IRs98M1y/Shz
rL4YiRWdRpfeHofcfOt0vStfCIIbtavjcQkQczbo2KZHjUmbp+7BRrL1Jvidg2bd
op3CX8iZCq0BTipjQcEkJzZN2NuHgN8aswKhbxxUfS1tjD9tWhNblu95bu+xuf/c
lpKCHHp5q7kw15bWNgb8NrRaJesMl9yhId9Qx4GXpZ4vJDwN2yoew6Y6m+bPKq78
vyIOStrP63ku46+M7VhTjtnFMg/CELPFVzQLmVTmjG+Be4/UmpFZs54vh7UC784H
q6j4V944ZO3VGGw0VcS2d1eh2Q4XHO6aTZkUMP8mioADjAaEB0kgKsV1d7yHpH2n
XOQ8D9FYr1R1zE1E6f63pmdhHUTbXQRoieomQDW6BvQ5QqV2QG0HZ17o28g0H96L
AcKSiGnKIV8CkiELtR9x
=RcyU
-----END PGP SIGNATURE-----

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3ba7470041de04ca88308f501901b574169cb517d3192397074611b3921a2dfa
size 1484336

17
kmod-18.tar.sign Normal file
View File

@ -0,0 +1,17 @@
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQIcBAABAgAGBQJTnG6zAAoJEJuipaYwy+pTyPkP/imTpAH2BC0rFkew2DRV9PsT
UYmS9HxSxdB5UNgew+7mpns1g5qnta24y5IECWNIYqlUq0LWloc55NwQFkiNSz5F
aZE144rejAer2w91GtEAzejIEa67IGjEWClWP69GO0ijhDis1/M8fEOnfCaGLgUK
cCGyhq+yE92Ek9lB1YV3MTrU4iybz2v5EUjQlK2guWkono0ujW+5mOAT16x4mVOR
k7Q7jfiLVuU89oqAjU8FJrYGoCNvZEw2Lw/TpnIz3tdFBCLn+rE9HKp03yKH6Cpb
LWTsrWOElx95nyIsPdwATtdsZnv9FjOFvxdEyTPpuxZPwnvxK44E2W8mQ9U7Kmb9
swBNbJKYVLufqYnkE7hArpSkcte/cFxVuyaSnIiqzgcFjNWCa8vx98iGzryt1mHB
Ff1GPsIX300O/vzzO/LEXJjs1bV9N9B7JXocRyf5YDnJJftvtgMrD1Lx1WZlrSmW
oiule9hfcxJRZJOHyuIhPjOp8Q8vwgSetMGDTTgzWd6NULStukE7tDj/bwdr8DiZ
x59IeargaCirpO1ePlp30T3Kl26e+oblVdQRAv4mA3pyTFbzi1U0KMf6gqq0Bv6e
T8YRGuWEZOpvd6L9g0t/osiKBeIMZfUp7tP/1+Qydc7ESx/n9eQx2dp11OWIdUTE
HnO4bckdcnlemdNkNr7L
=3wwv
-----END PGP SIGNATURE-----

3
kmod-18.tar.xz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e16e57272b54acb219c465b334715cfdddb5d97ff5d8948d4830ca1a372a868e
size 1473904

View File

@ -1,3 +1,15 @@
-------------------------------------------------------------------
Tue Jun 24 13:15:37 UTC 2014 - jengelh@inai.de
- Update to new upstream release 18
* Calling depmod with modules creating a dependency loop will now
make depmod return an error and not update the indexes. This is
to protect the current index not being overridden by another
index that may cause a boot failure, depending on the buggy module.
- Remove last vestiges of gpg-offline
- Remove 0001-depmod-Make-dependency-loops-be-fatal.patch
(applied upstream)
------------------------------------------------------------------- -------------------------------------------------------------------
Fri May 16 11:00:43 UTC 2014 - matwey.kornilov@gmail.com Fri May 16 11:00:43 UTC 2014 - matwey.kornilov@gmail.com

View File

@ -21,7 +21,7 @@ Name: kmod
Summary: Utilities to load modules into the kernel Summary: Utilities to load modules into the kernel
License: LGPL-2.1+ and GPL-2.0+ License: LGPL-2.1+ and GPL-2.0+
Group: System/Kernel Group: System/Kernel
Version: 17 Version: 18
Release: 0 Release: 0
Url: http://www.jonmasters.org/blog/2011/12/20/libkmod-replaces-module-init-tools/ Url: http://www.jonmasters.org/blog/2011/12/20/libkmod-replaces-module-init-tools/
#Announce: https://lwn.net/Articles/577962/ #Announce: https://lwn.net/Articles/577962/
@ -30,7 +30,6 @@ Url: http://www.jonmasters.org/blog/2011/12/20/libkmod-replaces-modul
#Git-Clone: git://git.kernel.org/pub/scm/utils/kernel/kmod/kmod #Git-Clone: git://git.kernel.org/pub/scm/utils/kernel/kmod/kmod
Source: ftp://ftp.kernel.org/pub/linux/utils/kernel/kmod/%name-%version.tar.xz Source: ftp://ftp.kernel.org/pub/linux/utils/kernel/kmod/%name-%version.tar.xz
Source2: ftp://ftp.kernel.org/pub/linux/utils/kernel/kmod/%name-%version.tar.sign Source2: ftp://ftp.kernel.org/pub/linux/utils/kernel/kmod/%name-%version.tar.sign
Patch1: 0001-depmod-Make-dependency-loops-be-fatal.patch
Patch2: 0002-modprobe-Recognize-allow-unsupported-modules-on-comm.patch Patch2: 0002-modprobe-Recognize-allow-unsupported-modules-on-comm.patch
Patch3: 0003-libkmod-config-Recognize-allow_unsupported_modules-i.patch Patch3: 0003-libkmod-config-Recognize-allow_unsupported_modules-i.patch
Patch9: 0009-libkmod-Implement-filtering-of-unsupported-modules-o.patch Patch9: 0009-libkmod-Implement-filtering-of-unsupported-modules-o.patch
@ -98,13 +97,8 @@ This package contains the development headers for the library found
in %lname. in %lname.
%prep %prep
%{?gpg_verify: xz -dk "%{S:0}"; %gpg_verify %{S:2}}
%setup -q %setup -q
%patch1 -p1 %patch -P 2 -P 3 -P 9 -P 10 -p1
%patch2 -p1
%patch3 -p1
%patch9 -p1
%patch10 -p1
%build %build
autoreconf -fi autoreconf -fi
@ -116,7 +110,7 @@ autoreconf -fi
%endif %endif
--with-xz \ --with-xz \
--with-zlib \ --with-zlib \
--includedir="%_includedir/%name-%version" \ --includedir="%_includedir/pkg/%name" \
--with-rootlibdir="%_libdir" \ --with-rootlibdir="%_libdir" \
--bindir="%_bindir" --bindir="%_bindir"
make %{?_smp_mflags} make %{?_smp_mflags}
@ -154,7 +148,7 @@ mkdir -p "$b"/{bin,sbin,%_lib};
ln -s "%_bindir/kmod" "$b/bin/"; ln -s "%_bindir/kmod" "$b/bin/";
%if "%_libdir" != "/%_lib" %if "%_libdir" != "/%_lib"
ln -s "%_libdir/libkmod.so.2" "$b/%_lib/"; ln -s "%_libdir/libkmod.so.2" "$b/%_lib/";
ln -s "%_libdir/libkmod.so.2.2.7" "$b/%_lib/"; ln -s "%_libdir/libkmod.so.2.2.8" "$b/%_lib/";
%endif %endif
%check %check