diff --git a/0001-Fix-recursion-loop-in-mod_count_all_dependencies-whe.patch b/0001-Fix-recursion-loop-in-mod_count_all_dependencies-whe.patch new file mode 100644 index 0000000..5816e1f --- /dev/null +++ b/0001-Fix-recursion-loop-in-mod_count_all_dependencies-whe.patch @@ -0,0 +1,76 @@ +From 48d4d7ba1acbb5c0955f75c6bdda9cf0935240fd Mon Sep 17 00:00:00 2001 +From: "Matwey V. Kornilov" +Date: Fri, 11 Apr 2014 19:43:18 +0400 +Subject: [PATCH] Fix recursion loop in mod_count_all_dependencies() when + subgraph has a cycle. + +When cycle is detected in mod_count_all_dependencies, use total count of +modules as an upper bound of needed memory. Correct number of nodes is determined by +subsequent call of mod_fill_all_unique_dependencies(). +--- + tools/depmod.c | 20 ++++++++++++++------ + 1 file changed, 14 insertions(+), 6 deletions(-) + +diff --git a/tools/depmod.c b/tools/depmod.c +index 1aedaaf..c83dee1 100644 +--- a/tools/depmod.c ++++ b/tools/depmod.c +@@ -1682,12 +1682,20 @@ static int depmod_load(struct depmod *depmod) + return 0; + } + +-static size_t mod_count_all_dependencies(const struct mod *mod) ++static size_t mod_count_all_dependencies(const struct mod *mod, size_t upper_bound) + { + size_t i, count = 0; ++ /* cycle is detected */ ++ if (mod->dep_loop) ++ return upper_bound; ++ + for (i = 0; i < mod->deps.count; i++) { + const struct mod *d = mod->deps.array[i]; +- count += 1 + mod_count_all_dependencies(d); ++ const size_t child = mod_count_all_dependencies(d, upper_bound); ++ if(child == upper_bound) ++ return child; ++ ++ count += 1 + child; + } + return count; + } +@@ -1722,12 +1730,12 @@ static int mod_fill_all_unique_dependencies(const struct mod *mod, const struct + return err; + } + +-static const struct mod **mod_get_all_sorted_dependencies(const struct mod *mod, size_t *n_deps) ++static const struct mod **mod_get_all_sorted_dependencies(const struct mod *mod, size_t *n_deps, size_t count) + { + const struct mod **deps; + size_t last = 0; + +- *n_deps = mod_count_all_dependencies(mod); ++ *n_deps = mod_count_all_dependencies(mod, count); + if (*n_deps == 0) + return NULL; + +@@ -1771,7 +1779,7 @@ static int output_deps(struct depmod *depmod, FILE *out) + if (mod->deps.count == 0) + goto end; + +- deps = mod_get_all_sorted_dependencies(mod, &n_deps); ++ deps = mod_get_all_sorted_dependencies(mod, &n_deps, depmod->modules.count); + if (deps == NULL) { + ERR("could not get all sorted dependencies of %s\n", p); + goto end; +@@ -1819,7 +1827,7 @@ static int output_deps_bin(struct depmod *depmod, FILE *out) + continue; + } + +- deps = mod_get_all_sorted_dependencies(mod, &n_deps); ++ deps = mod_get_all_sorted_dependencies(mod, &n_deps, depmod->modules.count); + if (deps == NULL && n_deps > 0) { + ERR("could not get all sorted dependencies of %s\n", p); + continue; +-- +1.8.1.4 + diff --git a/kmod.changes b/kmod.changes index 68e7d73..0430804 100644 --- a/kmod.changes +++ b/kmod.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Sat Apr 12 12:33:16 UTC 2014 - matwey.kornilov@gmail.com + +- Add 0001-Fix-recursion-loop-in-mod_count_all_dependencies-whe.patch +* Fix segfault at cycled deps (bnc#872715) + ------------------------------------------------------------------- Tue Apr 8 08:36:22 UTC 2014 - mmarek@suse.cz diff --git a/kmod.spec b/kmod.spec index 6da839b..73f72ce 100644 --- a/kmod.spec +++ b/kmod.spec @@ -30,6 +30,7 @@ Url: http://www.jonmasters.org/blog/2011/12/20/libkmod-replaces-modul #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 Source2: ftp://ftp.kernel.org/pub/linux/utils/kernel/kmod/%name-%version.tar.sign +Patch1: 0001-Fix-recursion-loop-in-mod_count_all_dependencies-whe.patch Patch2: 0002-modprobe-Recognize-allow-unsupported-modules-on-comm.patch Patch3: 0003-libkmod-config-Recognize-allow_unsupported_modules-i.patch Patch9: 0009-libkmod-Implement-filtering-of-unsupported-modules-o.patch @@ -99,6 +100,7 @@ in %lname. %prep %{?gpg_verify: xz -dk "%{S:0}"; %gpg_verify %{S:2}} %setup -q +%patch1 -p1 %patch2 -p1 %patch3 -p1 %patch9 -p1