From 237161f1b6a4b94e405978a3f000a711157a4d5fe9cfda019912e24be6d097d3 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Wed, 5 Mar 2014 15:59:07 +0000 Subject: [PATCH 1/6] Accepting request 224726 from home:michal-m:branches:Base:System - testsuite: Check the list of loaded modules after a test - testsuite: Add test for modprobe --force - testsuite: Do not provide finit_module(2) on older kernels - Add some tests for kernels without finit_module(2) - libkmod-module: Simplify kmod_module_insert_module() - libkmod: Implement filtering of unsupported modules (fate#316971) - modprobe: Implement --allow-unsupported-modules (fate#316971) - make the %check section fatal OBS-URL: https://build.opensuse.org/request/show/224726 OBS-URL: https://build.opensuse.org/package/show/Base:System/kmod?expand=0&rev=65 --- ...mod-w-documentation-and-getopt-entry.patch | 7 +- ...ze-allow-unsupported-modules-on-comm.patch | 5 +- ...ecognize-allow_unsupported_modules-i.patch | 5 +- ...the-list-of-loaded-modules-after-a-t.patch | 319 ++++++++++++++++++ ...estsuite-Add-test-for-modprobe-force.patch | 59 ++++ ...-provide-finit_module-2-on-older-ker.patch | 67 ++++ ...s-for-kernels-without-finit_module-2.patch | 79 +++++ ...e-Simplify-kmod_module_insert_module.patch | 95 ++++++ ...t-filtering-of-unsupported-modules-o.patch | 108 ++++++ ...-Implement-allow-unsupported-modules.patch | 102 ++++++ kmod.changes | 12 + kmod.spec | 20 +- test-files.tar.xz | 3 + 13 files changed, 872 insertions(+), 9 deletions(-) create mode 100644 0004-testsuite-Check-the-list-of-loaded-modules-after-a-t.patch create mode 100644 0005-testsuite-Add-test-for-modprobe-force.patch create mode 100644 0006-testsuite-Do-not-provide-finit_module-2-on-older-ker.patch create mode 100644 0007-Add-some-tests-for-kernels-without-finit_module-2.patch create mode 100644 0008-libkmod-module-Simplify-kmod_module_insert_module.patch create mode 100644 0009-libkmod-Implement-filtering-of-unsupported-modules-o.patch create mode 100644 0010-modprobe-Implement-allow-unsupported-modules.patch create mode 100644 test-files.tar.xz diff --git a/0001-Remove-rmmod-w-documentation-and-getopt-entry.patch b/0001-Remove-rmmod-w-documentation-and-getopt-entry.patch index 55bb24b..f3a53f4 100644 --- a/0001-Remove-rmmod-w-documentation-and-getopt-entry.patch +++ b/0001-Remove-rmmod-w-documentation-and-getopt-entry.patch @@ -1,12 +1,13 @@ -From f81194e28e56dd57588edb5f19c5a3b1f38d1eb8 Mon Sep 17 00:00:00 2001 +From abf0e3b4ddb0c7348492309f8ccccdcafba91b2f Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Sun, 26 Jan 2014 18:00:23 -0200 -Subject: [PATCH 1/3] Remove "rmmod -w" documentation and getopt entry +Subject: [PATCH 01/10] Remove "rmmod -w" documentation and getopt entry This patch removes the cmdopts declaration and the documentation. They were leftover from the -w removal. -(cherry picked from commit a4bd1441e5c7e8903a9ae065801d4f06f13d06e9) +Patch-mainline: v17 +Git-commit: a4bd1441e5c7e8903a9ae065801d4f06f13d06e9 [mmarek: regenerated man/rmmod.8] --- man/rmmod.8 | 12 +----------- diff --git a/0002-modprobe-Recognize-allow-unsupported-modules-on-comm.patch b/0002-modprobe-Recognize-allow-unsupported-modules-on-comm.patch index ef5580d..9e0fa2f 100644 --- a/0002-modprobe-Recognize-allow-unsupported-modules-on-comm.patch +++ b/0002-modprobe-Recognize-allow-unsupported-modules-on-comm.patch @@ -1,13 +1,14 @@ -From 472b40d53f6a9121ade7b969151b5b14268d1172 Mon Sep 17 00:00:00 2001 +From 820ce4a006eeb230ee597e7565b17cec464ef15d Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Wed, 26 Feb 2014 13:48:55 +0100 -Subject: [PATCH 2/3] modprobe: Recognize --allow-unsupported-modules on +Subject: [PATCH 02/10] modprobe: Recognize --allow-unsupported-modules on commandline The option does not do anything yet, but it does not return error either. References: fate#316971 +Patch-mainline: never --- tools/modprobe.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/0003-libkmod-config-Recognize-allow_unsupported_modules-i.patch b/0003-libkmod-config-Recognize-allow_unsupported_modules-i.patch index a9a2c85..4c538f1 100644 --- a/0003-libkmod-config-Recognize-allow_unsupported_modules-i.patch +++ b/0003-libkmod-config-Recognize-allow_unsupported_modules-i.patch @@ -1,10 +1,11 @@ -From da1cb1dd16edb2533ac431793e5bb3d01b243cae Mon Sep 17 00:00:00 2001 +From 717e10547654bceebbcb84144be72a40d78e577a Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Wed, 26 Feb 2014 13:53:38 +0100 -Subject: [PATCH 3/3] libkmod-config: Recognize allow_unsupported_modules in +Subject: [PATCH 03/10] libkmod-config: Recognize allow_unsupported_modules in the configuration References: fate#316971 +Patch-mainline: never --- libkmod/libkmod-config.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/0004-testsuite-Check-the-list-of-loaded-modules-after-a-t.patch b/0004-testsuite-Check-the-list-of-loaded-modules-after-a-t.patch new file mode 100644 index 0000000..9ac2182 --- /dev/null +++ b/0004-testsuite-Check-the-list-of-loaded-modules-after-a-t.patch @@ -0,0 +1,319 @@ +From 525e74c84547001548840f7a909350b366ed9b30 Mon Sep 17 00:00:00 2001 +From: Michal Marek +Date: Thu, 27 Feb 2014 22:23:31 +0100 +Subject: [PATCH 04/10] testsuite: Check the list of loaded modules after a + test + +Add a ->modules_loaded member to struct test, which is a comma-separated +list of modules that should be present after the test finishes. Both +missing and excess modules cause an error. + +Patch-mainline: v17 +Git-commit: 88ac40840f0d13aaca844bb7198c252178968878 +--- + testsuite/test-init.c | 1 + + testsuite/test-modprobe.c | 13 +++- + testsuite/testsuite.c | 189 +++++++++++++++++++++++++++++++++++++++++++++- + testsuite/testsuite.h | 2 + + 4 files changed, 199 insertions(+), 6 deletions(-) + +diff --git a/testsuite/test-init.c b/testsuite/test-init.c +index 63b6501..d2aa4bd 100644 +--- a/testsuite/test-init.c ++++ b/testsuite/test-init.c +@@ -74,6 +74,7 @@ static DEFINE_TEST(test_insert, + [TC_ROOTFS] = TESTSUITE_ROOTFS "test-init/", + [TC_INIT_MODULE_RETCODES] = "bla:1:20", + }, ++ .modules_loaded = "ext4", + .need_spawn = true); + + static noreturn int test_remove(const struct test *t) +diff --git a/testsuite/test-modprobe.c b/testsuite/test-modprobe.c +index 637d363..c3ef31e 100644 +--- a/testsuite/test-modprobe.c ++++ b/testsuite/test-modprobe.c +@@ -91,7 +91,9 @@ static DEFINE_TEST(modprobe_show_alias_to_none, + }, + .output = { + .out = TESTSUITE_ROOTFS "test-modprobe/show-depends/correct-psmouse.txt", +- }); ++ }, ++ .modules_loaded = "", ++ ); + + + static noreturn int modprobe_builtin(const struct test *t) +@@ -131,7 +133,9 @@ static DEFINE_TEST(modprobe_softdep_loop, + [TC_UNAME_R] = "4.4.4", + [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/softdep-loop", + [TC_INIT_MODULE_RETCODES] = "", +- }); ++ }, ++ .modules_loaded = "btusb,bluetooth", ++ ); + + static noreturn int modprobe_install_cmd_loop(const struct test *t) + { +@@ -156,6 +160,7 @@ static DEFINE_TEST(modprobe_install_cmd_loop, + { "MODPROBE", ABS_TOP_BUILDDIR "/tools/modprobe" }, + { } + }, ++ .modules_loaded = "snd,snd-pcm", + ); + + static noreturn int modprobe_param_kcmdline(const struct test *t) +@@ -178,7 +183,9 @@ static DEFINE_TEST(modprobe_param_kcmdline, + }, + .output = { + .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline/correct.txt", +- }); ++ }, ++ .modules_loaded = "", ++ ); + + + static const struct test *tests[] = { +diff --git a/testsuite/testsuite.c b/testsuite/testsuite.c +index 9877a64..c29ca78 100644 +--- a/testsuite/testsuite.c ++++ b/testsuite/testsuite.c +@@ -20,6 +20,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -528,12 +529,189 @@ fail: + return true; + } + ++static int cmp_modnames(const void *m1, const void *m2) ++{ ++ const char *s1 = *(char *const *)m1; ++ const char *s2 = *(char *const *)m2; ++ int i; ++ ++ for (i = 0; s1[i] || s2[i]; i++) { ++ char c1 = s1[i], c2 = s2[i]; ++ if (c1 == '-') ++ c1 = '_'; ++ if (c2 == '-') ++ c2 = '_'; ++ if (c1 != c2) ++ return c1 - c2; ++ } ++ return 0; ++} ++ ++/* ++ * Store the expected module names in buf and return a list of pointers to ++ * them. ++ */ ++static const char **read_expected_modules(const struct test *t, ++ char **buf, int *count) ++{ ++ const char **res; ++ int len; ++ int i; ++ char *p; ++ ++ if (t->modules_loaded[0] == '\0') { ++ *count = 0; ++ *buf = NULL; ++ return NULL; ++ } ++ *buf = strdup(t->modules_loaded); ++ if (!*buf) { ++ *count = -1; ++ return NULL; ++ } ++ len = 1; ++ for (p = *buf; *p; p++) ++ if (*p == ',') ++ len++; ++ res = malloc(sizeof(char *) * len); ++ if (!res) { ++ perror("malloc"); ++ *count = -1; ++ free(*buf); ++ *buf = NULL; ++ return NULL; ++ } ++ i = 0; ++ res[i++] = *buf; ++ for (p = *buf; i < len; p++) ++ if (*p == ',') { ++ *p = '\0'; ++ res[i++] = p + 1; ++ } ++ *count = len; ++ return res; ++} ++ ++static char **read_loaded_modules(const struct test *t, char **buf, int *count) ++{ ++ char dirname[PATH_MAX]; ++ DIR *dir; ++ struct dirent *dirent; ++ int i; ++ int len = 0, bufsz; ++ char **res = NULL; ++ char *p; ++ const char *rootfs = t->config[TC_ROOTFS] ? t->config[TC_ROOTFS] : ""; ++ ++ /* Store the entries in /sys/module to res */ ++ if (snprintf(dirname, sizeof(dirname), "%s/sys/module", rootfs) ++ >= (int)sizeof(dirname)) { ++ ERR("rootfs path too long: %s\n", rootfs); ++ *buf = NULL; ++ len = -1; ++ goto out; ++ } ++ dir = opendir(dirname); ++ /* not an error, simply return empty list */ ++ if (!dir) { ++ *buf = NULL; ++ goto out; ++ } ++ bufsz = 0; ++ while ((dirent = readdir(dir))) { ++ if (dirent->d_name[0] == '.') ++ continue; ++ len++; ++ bufsz += strlen(dirent->d_name) + 1; ++ } ++ res = malloc(sizeof(char *) * len); ++ if (!res) { ++ perror("malloc"); ++ len = -1; ++ goto out_dir; ++ } ++ *buf = malloc(bufsz); ++ if (!*buf) { ++ perror("malloc"); ++ free(res); ++ res = NULL; ++ len = -1; ++ goto out_dir; ++ } ++ rewinddir(dir); ++ i = 0; ++ p = *buf; ++ while ((dirent = readdir(dir))) { ++ int size; ++ ++ if (dirent->d_name[0] == '.') ++ continue; ++ size = strlen(dirent->d_name) + 1; ++ memcpy(p, dirent->d_name, size); ++ res[i++] = p; ++ p += size; ++ } ++out_dir: ++ closedir(dir); ++out: ++ *count = len; ++ return res; ++} ++ ++static int check_loaded_modules(const struct test *t) ++{ ++ int l1, l2, i1, i2; ++ const char **a1; ++ char **a2; ++ char *buf1, *buf2; ++ int err = false; ++ ++ a1 = read_expected_modules(t, &buf1, &l1); ++ if (l1 < 0) ++ return err; ++ a2 = read_loaded_modules(t, &buf2, &l2); ++ if (l2 < 0) ++ goto out_a1; ++ qsort(a1, l1, sizeof(char *), cmp_modnames); ++ qsort(a2, l2, sizeof(char *), cmp_modnames); ++ i1 = i2 = 0; ++ err = true; ++ while (i1 < l1 || i2 < l2) { ++ int cmp; ++ ++ if (i1 >= l1) ++ cmp = 1; ++ else if (i2 >= l2) ++ cmp = -1; ++ else ++ cmp = cmp_modnames(&a1[i1], &a2[i2]); ++ if (cmp == 0) { ++ i1++; ++ i2++; ++ } else if (cmp < 0) { ++ err = false; ++ ERR("module %s not loaded\n", a1[i1]); ++ i1++; ++ } else { ++ err = false; ++ ERR("module %s is loaded but should not be \n", a2[i2]); ++ i2++; ++ } ++ } ++ free(a2); ++ free(buf2); ++out_a1: ++ free(a1); ++ free(buf1); ++ return err; ++} ++ + static inline int test_run_parent(const struct test *t, int fdout[2], + int fderr[2], int fdmonitor[2], pid_t child) + { + pid_t pid; + int err; +- bool matchout; ++ bool matchout, match_modules; + + /* Close write-fds */ + if (t->output.out != NULL) +@@ -578,16 +756,21 @@ static inline int test_run_parent(const struct test *t, int fdout[2], + + if (matchout) + matchout = check_generated_files(t); ++ if (t->modules_loaded) ++ match_modules = check_loaded_modules(t); ++ else ++ match_modules = true; + + if (t->expected_fail == false) { + if (err == 0) { +- if (matchout) ++ if (matchout && match_modules) + LOG("%sPASSED%s: %s\n", + ANSI_HIGHLIGHT_GREEN_ON, ANSI_HIGHLIGHT_OFF, + t->name); + else { +- ERR("%sFAILED%s: exit ok but outputs do not match: %s\n", ++ ERR("%sFAILED%s: exit ok but %s do not match: %s\n", + ANSI_HIGHLIGHT_RED_ON, ANSI_HIGHLIGHT_OFF, ++ matchout ? "loaded modules" : "outputs", + t->name); + err = EXIT_FAILURE; + } +diff --git a/testsuite/testsuite.h b/testsuite/testsuite.h +index 97183cd..f2a75e5 100644 +--- a/testsuite/testsuite.h ++++ b/testsuite/testsuite.h +@@ -95,6 +95,8 @@ struct test { + */ + const struct keyval *files; + } output; ++ /* comma-separated list of loaded modules at the end of the test */ ++ const char *modules_loaded; + testfunc func; + const char *config[_TC_LAST]; + const char *path; +-- +1.8.4.5 + diff --git a/0005-testsuite-Add-test-for-modprobe-force.patch b/0005-testsuite-Add-test-for-modprobe-force.patch new file mode 100644 index 0000000..9fe5ae0 --- /dev/null +++ b/0005-testsuite-Add-test-for-modprobe-force.patch @@ -0,0 +1,59 @@ +From 5b532fd9616ba2a750e25378152bad4c9a2e7c27 Mon Sep 17 00:00:00 2001 +From: Michal Marek +Date: Thu, 27 Feb 2014 22:34:24 +0100 +Subject: [PATCH 05/10] testsuite: Add test for modprobe --force + +There is no check if the correct flags are passed to finit_module, but +at least we cover the respective code path in kmod. + +Patch-mainline: v17 +Git-commit: 2ce5de0ae6c191920a4eeeab757ccfad092d9e0f +[mmarek: Dropped binary files from the patch] +--- + testsuite/test-modprobe.c | 23 +++++++++++++++++++++++ + 1 file changed, 23 insertions(+) + +diff --git a/testsuite/test-modprobe.c b/testsuite/test-modprobe.c +index c3ef31e..92348b0 100644 +--- a/testsuite/test-modprobe.c ++++ b/testsuite/test-modprobe.c +@@ -187,6 +187,28 @@ static DEFINE_TEST(modprobe_param_kcmdline, + .modules_loaded = "", + ); + ++static noreturn int modprobe_force(const struct test *t) ++{ ++ const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; ++ const char *const args[] = { ++ progname, ++ "--force", "psmouse", ++ NULL, ++ }; ++ ++ test_spawn_prog(progname, args); ++ exit(EXIT_FAILURE); ++} ++static DEFINE_TEST(modprobe_force, ++ .description = "check modprobe --force", ++ .config = { ++ [TC_UNAME_R] = "4.4.4", ++ [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/force", ++ [TC_INIT_MODULE_RETCODES] = "", ++ }, ++ .modules_loaded = "psmouse", ++ ); ++ + + static const struct test *tests[] = { + &smodprobe_show_depends, +@@ -196,6 +218,7 @@ static const struct test *tests[] = { + &smodprobe_softdep_loop, + &smodprobe_install_cmd_loop, + &smodprobe_param_kcmdline, ++ &smodprobe_force, + NULL, + }; + +-- +1.8.4.5 + diff --git a/0006-testsuite-Do-not-provide-finit_module-2-on-older-ker.patch b/0006-testsuite-Do-not-provide-finit_module-2-on-older-ker.patch new file mode 100644 index 0000000..90e24f4 --- /dev/null +++ b/0006-testsuite-Do-not-provide-finit_module-2-on-older-ker.patch @@ -0,0 +1,67 @@ +From 970b96f070b3f9ccd9c1850db44116a2b02da424 Mon Sep 17 00:00:00 2001 +From: Michal Marek +Date: Thu, 27 Feb 2014 23:31:33 +0100 +Subject: [PATCH 06/10] testsuite: Do not provide finit_module(2) on older + kernels + +If the test's uname -r is less that 3.8, return -ENOSYS from +finit_module(), so that the fallback is tested. + +Patch-mainline: v17 +Git-commit: 063086e038657de64f9980bc51954b0817fa8e6c +--- + testsuite/init_module.c | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) + +diff --git a/testsuite/init_module.c b/testsuite/init_module.c +index 42177e7..269a471 100644 +--- a/testsuite/init_module.c ++++ b/testsuite/init_module.c +@@ -37,6 +37,7 @@ + #include + #include + #include ++#include + #include + + /* kmod_elf_get_section() is not exported, we need the private header */ +@@ -280,6 +281,25 @@ long init_module(void *mem, unsigned long len, const char *args) + return err; + } + ++static int check_kernel_version(int major, int minor) ++{ ++ struct utsname u; ++ const char *p; ++ int maj = 0, min = 0; ++ ++ if (uname(&u) < 0) ++ return false; ++ for (p = u.release; *p >= '0' && *p <= '9'; p++) ++ maj = maj * 10 + *p - '0'; ++ if (*p == '.') ++ for (p++; *p >= '0' && *p <= '9'; p++) ++ min = min * 10 + *p - '0'; ++ if (maj > major || (maj == major && min >= minor)) ++ return true; ++ return false; ++} ++ ++ + TS_EXPORT int finit_module(const int fd, const char *args, const int flags); + + int finit_module(const int fd, const char *args, const int flags) +@@ -289,6 +309,10 @@ int finit_module(const int fd, const char *args, const int flags) + unsigned long len; + struct stat st; + ++ if (!check_kernel_version(3, 8)) { ++ errno = ENOSYS; ++ return -1; ++ } + if (fstat(fd, &st) < 0) + return -1; + +-- +1.8.4.5 + diff --git a/0007-Add-some-tests-for-kernels-without-finit_module-2.patch b/0007-Add-some-tests-for-kernels-without-finit_module-2.patch new file mode 100644 index 0000000..ccdf949 --- /dev/null +++ b/0007-Add-some-tests-for-kernels-without-finit_module-2.patch @@ -0,0 +1,79 @@ +From 9a23dec3269fad1c4f03f6b9b4ceccedc136d4e2 Mon Sep 17 00:00:00 2001 +From: Michal Marek +Date: Thu, 27 Feb 2014 23:33:38 +0100 +Subject: [PATCH 07/10] Add some tests for kernels without finit_module(2) + +Patch-mainline: v17 +Git-commit: be29c40e25b71d35708b9fad5772ebcd8e4685b3 +[mmarek: Dropped binary files from the patch] +--- + testsuite/test-modprobe.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 46 insertions(+) + +diff --git a/testsuite/test-modprobe.c b/testsuite/test-modprobe.c +index 92348b0..b675f48 100644 +--- a/testsuite/test-modprobe.c ++++ b/testsuite/test-modprobe.c +@@ -209,6 +209,50 @@ static DEFINE_TEST(modprobe_force, + .modules_loaded = "psmouse", + ); + ++static noreturn int modprobe_oldkernel(const struct test *t) ++{ ++ const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; ++ const char *const args[] = { ++ progname, ++ "psmouse", ++ NULL, ++ }; ++ ++ test_spawn_prog(progname, args); ++ exit(EXIT_FAILURE); ++} ++static DEFINE_TEST(modprobe_oldkernel, ++ .description = "check modprobe --force", ++ .config = { ++ [TC_UNAME_R] = "3.3.3", ++ [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/oldkernel", ++ [TC_INIT_MODULE_RETCODES] = "", ++ }, ++ .modules_loaded = "psmouse", ++ ); ++ ++static noreturn int modprobe_oldkernel_force(const struct test *t) ++{ ++ const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; ++ const char *const args[] = { ++ progname, ++ "--force", "psmouse", ++ NULL, ++ }; ++ ++ test_spawn_prog(progname, args); ++ exit(EXIT_FAILURE); ++} ++static DEFINE_TEST(modprobe_oldkernel_force, ++ .description = "check modprobe --force", ++ .config = { ++ [TC_UNAME_R] = "3.3.3", ++ [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/oldkernel-force", ++ [TC_INIT_MODULE_RETCODES] = "", ++ }, ++ .modules_loaded = "psmouse", ++ ); ++ + + static const struct test *tests[] = { + &smodprobe_show_depends, +@@ -219,6 +263,8 @@ static const struct test *tests[] = { + &smodprobe_install_cmd_loop, + &smodprobe_param_kcmdline, + &smodprobe_force, ++ &smodprobe_oldkernel, ++ &smodprobe_oldkernel_force, + NULL, + }; + +-- +1.8.4.5 + diff --git a/0008-libkmod-module-Simplify-kmod_module_insert_module.patch b/0008-libkmod-module-Simplify-kmod_module_insert_module.patch new file mode 100644 index 0000000..d92fb4b --- /dev/null +++ b/0008-libkmod-module-Simplify-kmod_module_insert_module.patch @@ -0,0 +1,95 @@ +From 40926774b6153bfd7f0321b3226323958bc4d81d Mon Sep 17 00:00:00 2001 +From: Michal Marek +Date: Thu, 27 Feb 2014 11:32:22 +0100 +Subject: [PATCH 08/10] libkmod-module: Simplify kmod_module_insert_module() + +Store the file and elf pointer in the kmod_module structure and have it +freed together with the module. + +Patch-mainline: v17 +Git-commit: c2f4d85a9adea895958fc85b9b87ce95a7dc7774 +--- + libkmod/libkmod-module.c | 27 ++++++++++----------------- + 1 file changed, 10 insertions(+), 17 deletions(-) + +diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c +index 2f92e16..b94abd4 100644 +--- a/libkmod/libkmod-module.c ++++ b/libkmod/libkmod-module.c +@@ -791,8 +791,7 @@ KMOD_EXPORT int kmod_module_insert_module(struct kmod_module *mod, + int err; + const void *mem; + off_t size; +- struct kmod_file *file; +- struct kmod_elf *elf = NULL; ++ struct kmod_elf *elf; + const char *path; + const char *args = options ? options : ""; + +@@ -805,13 +804,13 @@ KMOD_EXPORT int kmod_module_insert_module(struct kmod_module *mod, + return -ENOSYS; + } + +- file = kmod_file_open(mod->ctx, path); +- if (file == NULL) { ++ mod->file = kmod_file_open(mod->ctx, path); ++ if (mod->file == NULL) { + err = -errno; + return err; + } + +- if (kmod_file_get_direct(file)) { ++ if (kmod_file_get_direct(mod->file)) { + unsigned int kernel_flags = 0; + + if (flags & KMOD_INSERT_FORCE_VERMAGIC) +@@ -819,19 +818,16 @@ KMOD_EXPORT int kmod_module_insert_module(struct kmod_module *mod, + if (flags & KMOD_INSERT_FORCE_MODVERSION) + kernel_flags |= MODULE_INIT_IGNORE_MODVERSIONS; + +- err = finit_module(kmod_file_get_fd(file), args, kernel_flags); ++ err = finit_module(kmod_file_get_fd(mod->file), args, kernel_flags); + if (err == 0 || errno != ENOSYS) + goto init_finished; + } + +- size = kmod_file_get_size(file); +- mem = kmod_file_get_contents(file); +- + if (flags & (KMOD_INSERT_FORCE_VERMAGIC | KMOD_INSERT_FORCE_MODVERSION)) { +- elf = kmod_elf_new(mem, size); ++ elf = kmod_file_get_elf(mod->file); + if (elf == NULL) { + err = -errno; +- goto elf_failed; ++ return err; + } + + if (flags & KMOD_INSERT_FORCE_MODVERSION) { +@@ -847,7 +843,10 @@ KMOD_EXPORT int kmod_module_insert_module(struct kmod_module *mod, + } + + mem = kmod_elf_get_memory(elf); ++ } else { ++ mem = kmod_file_get_contents(mod->file); + } ++ size = kmod_file_get_size(mod->file); + + err = init_module(mem, size, args); + init_finished: +@@ -855,12 +854,6 @@ init_finished: + err = -errno; + INFO(mod->ctx, "Failed to insert module '%s': %m\n", path); + } +- +- if (elf != NULL) +- kmod_elf_unref(elf); +-elf_failed: +- kmod_file_unref(file); +- + return err; + } + +-- +1.8.4.5 + diff --git a/0009-libkmod-Implement-filtering-of-unsupported-modules-o.patch b/0009-libkmod-Implement-filtering-of-unsupported-modules-o.patch new file mode 100644 index 0000000..3f57da9 --- /dev/null +++ b/0009-libkmod-Implement-filtering-of-unsupported-modules-o.patch @@ -0,0 +1,108 @@ +From 36bb8bc7f4100d7ffc4d6d0436e36e48fa7c075f Mon Sep 17 00:00:00 2001 +From: Michal Marek +Date: Wed, 5 Mar 2014 14:40:14 +0100 +Subject: [PATCH 09/10] libkmod: Implement filtering of unsupported modules + (off by default) + +References: fate#316971 +Patch-mainline: never +--- + libkmod/libkmod-config.c | 12 ++++++++++-- + libkmod/libkmod-internal.h | 1 + + libkmod/libkmod-module.c | 31 +++++++++++++++++++++++++++++++ + 3 files changed, 42 insertions(+), 2 deletions(-) + +diff --git a/libkmod/libkmod-config.c b/libkmod/libkmod-config.c +index 3950923..385a224 100644 +--- a/libkmod/libkmod-config.c ++++ b/libkmod/libkmod-config.c +@@ -663,8 +663,16 @@ static int kmod_config_parse(struct kmod_config *config, int fd, + ERR(ctx, "%s: command %s is deprecated and not parsed anymore\n", + filename, cmd); + } else if (streq(cmd, "allow_unsupported_modules")) { +- /* dummy option for now */ +- ; ++ char *param = strtok_r(NULL, "\t ", &saveptr); ++ ++ if (param == NULL) ++ goto syntax_error; ++ if (streq(param, "yes") || streq(param, "1")) ++ config->block_unsupported = 0; ++ else if (streq(param, "no") || streq(param, "0")) ++ config->block_unsupported = 1; ++ else ++ goto syntax_error; + } else { + syntax_error: + ERR(ctx, "%s line %u: ignoring bad line starting with '%s'\n", +diff --git a/libkmod/libkmod-internal.h b/libkmod/libkmod-internal.h +index 0180124..596db5d 100644 +--- a/libkmod/libkmod-internal.h ++++ b/libkmod/libkmod-internal.h +@@ -118,6 +118,7 @@ struct kmod_config { + struct kmod_list *softdeps; + + struct kmod_list *paths; ++ int block_unsupported; + }; + + int kmod_config_new(struct kmod_ctx *ctx, struct kmod_config **config, const char * const *config_paths) __attribute__((nonnull(1, 2,3))); +diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c +index b94abd4..ee52b97 100644 +--- a/libkmod/libkmod-module.c ++++ b/libkmod/libkmod-module.c +@@ -769,6 +769,24 @@ KMOD_EXPORT int kmod_module_remove_module(struct kmod_module *mod, + + extern long init_module(const void *mem, unsigned long len, const char *args); + ++static int check_module_supported(struct kmod_module *mod) ++{ ++ char **strings; ++ int i, count; ++ struct kmod_elf *elf; ++ ++ elf = kmod_file_get_elf(mod->file); ++ count = kmod_elf_get_strings(elf, ".modinfo", &strings); ++ if (count < 0) ++ return count; ++ for (i = 0; i < count; i++) ++ if (streq(strings[i], "supported=yes") || ++ streq(strings[i], "supported=external")) { ++ return 1; ++ } ++ return 0; ++} ++ + /** + * kmod_module_insert_module: + * @mod: kmod module +@@ -794,6 +812,7 @@ KMOD_EXPORT int kmod_module_insert_module(struct kmod_module *mod, + struct kmod_elf *elf; + const char *path; + const char *args = options ? options : ""; ++ const struct kmod_config *config = kmod_get_config(mod->ctx); + + if (mod == NULL) + return -ENOENT; +@@ -810,6 +829,18 @@ KMOD_EXPORT int kmod_module_insert_module(struct kmod_module *mod, + return err; + } + ++ if (config->block_unsupported) { ++ err = check_module_supported(mod); ++ if (err < 0) ++ return err; ++ else if (err == 0) { ++ ERR(mod->ctx, "module '%s' is unsupported\n", mod->name); ++ ERR(mod->ctx, "Use --allow-unsupported or set allow_unsupported_modules 1 in\n"); ++ ERR(mod->ctx, "/etc/modprobe.d/10-unsupported-modules.conf\n"); ++ return -EPERM; ++ } ++ } ++ + if (kmod_file_get_direct(mod->file)) { + unsigned int kernel_flags = 0; + +-- +1.8.4.5 + diff --git a/0010-modprobe-Implement-allow-unsupported-modules.patch b/0010-modprobe-Implement-allow-unsupported-modules.patch new file mode 100644 index 0000000..164c9d5 --- /dev/null +++ b/0010-modprobe-Implement-allow-unsupported-modules.patch @@ -0,0 +1,102 @@ +From 714b9b5241f5fc6120c74f35d6a374e032bad6df Mon Sep 17 00:00:00 2001 +From: Michal Marek +Date: Wed, 5 Mar 2014 15:02:44 +0100 +Subject: [PATCH 10/10] modprobe: Implement --allow-unsupported-modules + +References: fate#316971 +Patch-mainline: never +--- + Makefile.am | 4 +++- + libkmod/libkmod-unsupported.c | 9 +++++++++ + libkmod/libkmod-unsupported.h | 8 ++++++++ + tools/modprobe.c | 7 ++++++- + 4 files changed, 26 insertions(+), 2 deletions(-) + create mode 100644 libkmod/libkmod-unsupported.c + create mode 100644 libkmod/libkmod-unsupported.h + +diff --git a/Makefile.am b/Makefile.am +index 46b7652..9986730 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -78,7 +78,9 @@ libkmod_libkmod_la_LIBADD = libkmod/libkmod-util.la \ + ${liblzma_LIBS} ${zlib_LIBS} + + noinst_LTLIBRARIES += libkmod/libkmod-internal.la +-libkmod_libkmod_internal_la_SOURCES = $(libkmod_libkmod_la_SOURCES) ++libkmod_libkmod_internal_la_SOURCES = $(libkmod_libkmod_la_SOURCES) \ ++ libkmod/libkmod-unsupported.c \ ++ libkmod/libkmod-unsupported.h + libkmod_libkmod_internal_la_LDFLAGS = $(AM_LDFLAGS) \ + -Wl,--version-script=$(top_srcdir)/libkmod/libkmod.sym + libkmod_libkmod_internal_la_DEPENDENCIES = $(libkmod_libkmod_la_DEPENDENCIES) +diff --git a/libkmod/libkmod-unsupported.c b/libkmod/libkmod-unsupported.c +new file mode 100644 +index 0000000..7ef9fc8 +--- /dev/null ++++ b/libkmod/libkmod-unsupported.c +@@ -0,0 +1,9 @@ ++#include "libkmod-internal.h" ++#include "libkmod-unsupported.h" ++ ++void kmod_internal_allow_unsupported(struct kmod_ctx *ctx) ++{ ++ struct kmod_config *config = (struct kmod_config *)kmod_get_config(ctx); ++ ++ config->block_unsupported = 0; ++} +diff --git a/libkmod/libkmod-unsupported.h b/libkmod/libkmod-unsupported.h +new file mode 100644 +index 0000000..a95b4a2 +--- /dev/null ++++ b/libkmod/libkmod-unsupported.h +@@ -0,0 +1,8 @@ ++#pragma once ++ ++/* ++ * This function implements the --allow-unsupported-modules modprobe ++ * option. It is not part of the kmod API and not exported by the shared ++ * library ++ */ ++void kmod_internal_allow_unsupported(struct kmod_ctx *ctx); +diff --git a/tools/modprobe.c b/tools/modprobe.c +index 589cc07..7d0949d 100644 +--- a/tools/modprobe.c ++++ b/tools/modprobe.c +@@ -33,6 +33,7 @@ + + #include "libkmod.h" + #include "libkmod-array.h" ++#include "libkmod-unsupported.h" + #include "macro.h" + + #include "kmod.h" +@@ -755,6 +756,7 @@ static int do_modprobe(int argc, char **orig_argv) + int do_remove = 0; + int do_show_config = 0; + int do_show_modversions = 0; ++ int allow_unsupported = 0; + int err; + + argv = prepend_options_from_env(&argc, orig_argv); +@@ -838,7 +840,7 @@ static int do_modprobe(int argc, char **orig_argv) + kversion = optarg; + break; + case 128: +- /* --allow-unsupported-modules does nothing for now */ ++ allow_unsupported = 1; + break; + case 's': + env_modprobe_options_append("-s"); +@@ -910,6 +912,9 @@ static int do_modprobe(int argc, char **orig_argv) + + log_setup_kmod_log(ctx, verbose); + ++ if (allow_unsupported) ++ kmod_internal_allow_unsupported(ctx); ++ + kmod_load_resources(ctx); + + if (do_show_config) +-- +1.8.4.5 + diff --git a/kmod.changes b/kmod.changes index 5017d89..7e1c20c 100644 --- a/kmod.changes +++ b/kmod.changes @@ -1,3 +1,15 @@ +------------------------------------------------------------------- +Wed Mar 5 14:50:34 UTC 2014 - mmarek@suse.cz + +- testsuite: Check the list of loaded modules after a test +- testsuite: Add test for modprobe --force +- testsuite: Do not provide finit_module(2) on older kernels +- Add some tests for kernels without finit_module(2) +- libkmod-module: Simplify kmod_module_insert_module() +- libkmod: Implement filtering of unsupported modules (fate#316971) +- modprobe: Implement --allow-unsupported-modules (fate#316971) +- make the %check section fatal + ------------------------------------------------------------------- Wed Feb 26 13:23:41 UTC 2014 - mmarek@suse.cz diff --git a/kmod.spec b/kmod.spec index 26e328a..6259db6 100644 --- a/kmod.spec +++ b/kmod.spec @@ -30,9 +30,18 @@ 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 +# Files that would have been added by patches 5 and 7 +Source3: test-files.tar.xz Patch1: 0001-Remove-rmmod-w-documentation-and-getopt-entry.patch Patch2: 0002-modprobe-Recognize-allow-unsupported-modules-on-comm.patch Patch3: 0003-libkmod-config-Recognize-allow_unsupported_modules-i.patch +Patch4: 0004-testsuite-Check-the-list-of-loaded-modules-after-a-t.patch +Patch5: 0005-testsuite-Add-test-for-modprobe-force.patch +Patch6: 0006-testsuite-Do-not-provide-finit_module-2-on-older-ker.patch +Patch7: 0007-Add-some-tests-for-kernels-without-finit_module-2.patch +Patch8: 0008-libkmod-module-Simplify-kmod_module_insert_module.patch +Patch9: 0009-libkmod-Implement-filtering-of-unsupported-modules-o.patch +Patch10: 0010-modprobe-Implement-allow-unsupported-modules.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: autoconf BuildRequires: automake @@ -101,11 +110,18 @@ in %lname. %prep %{?gpg_verify: xz -dk "%{S:0}"; %gpg_verify %{S:2}} -%setup -q +%setup -q -a 3 %patch1 -p1 touch man/rmmod.8 %patch2 -p1 %patch3 -p1 +%patch4 -p1 +%patch5 -p1 +%patch6 -p1 +%patch7 -p1 +%patch8 -p1 +%patch9 -p1 +%patch10 -p1 %build autoreconf -fi @@ -159,7 +175,7 @@ ln -s "%_libdir/libkmod.so.2.2.6" "$b/%_lib/"; %endif %check -make check V=1 || :; +make check %post -n %lname -p /sbin/ldconfig diff --git a/test-files.tar.xz b/test-files.tar.xz new file mode 100644 index 0000000..94e8b8f --- /dev/null +++ b/test-files.tar.xz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:71f16a0d75d3c1cff13c6eb7bf490f4fa59020d4b11b8eed3a8635b020fa162a +size 26776 From 17f675073d06dbfd6098b0f0fb362986d05b565f2a959daa39c0f20d835e287b Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Fri, 7 Mar 2014 15:06:38 +0000 Subject: [PATCH 2/6] Accepting request 224989 from home:michal-m:branches:Base:System - testsuite: Fix uname() during glibc startup OBS-URL: https://build.opensuse.org/request/show/224989 OBS-URL: https://build.opensuse.org/package/show/Base:System/kmod?expand=0&rev=66 --- ...suite-Fix-uname-during-glibc-startup.patch | 97 +++++++++++++++++++ kmod.changes | 5 + kmod.spec | 2 + 3 files changed, 104 insertions(+) create mode 100644 0001-testsuite-Fix-uname-during-glibc-startup.patch diff --git a/0001-testsuite-Fix-uname-during-glibc-startup.patch b/0001-testsuite-Fix-uname-during-glibc-startup.patch new file mode 100644 index 0000000..5394057 --- /dev/null +++ b/0001-testsuite-Fix-uname-during-glibc-startup.patch @@ -0,0 +1,97 @@ +From 4d392fa63af7f3fd09fdb49120864af1404d1a25 Mon Sep 17 00:00:00 2001 +From: Michal Marek +Date: Thu, 6 Mar 2014 18:03:46 +0100 +Subject: [PATCH] testsuite: Fix uname() during glibc startup + +In a specific configuration (chroot with the linux32 personality), the +modprobe_install_cmd_loop test failed, because the bash process handling +the install command segfaulted. The backtrace showed a uname() call +during libpthread initialization, at which point the environ pointer +hadn't been initialized yet: + + Program terminated with signal SIGSEGV, Segmentation fault. + #0 0x080c1591 in getenv (name=, + name@entry=0xf775f850 "TESTSUITE_UNAME_R") at getenv.c:81 + 81 for (i = 0, len = strlen (name); environ[i]; i++) + (gdb) bt + #0 0x080c1591 in getenv (name=, + name@entry=0xf775f850 "TESTSUITE_UNAME_R") at getenv.c:81 + #1 0xf775f754 in uname (u=u@entry=0xff946350) at testsuite/uname.c:32 + #2 0xf74ffc6c in is_smp_system () + at ../nptl/sysdeps/unix/sysv/linux/i386/smp.h:39 + #3 __pthread_initialize_minimal_internal () at nptl-init.c:460 + #4 0xf74fe32c in _init () at ../sysdeps/i386/crti.S:74 + #5 0x00000000 in ?? () + (gdb) p environ + $1 = (char **) 0x0 + +I don't know why it only happend in the chroot, but glibc can call its +own functions and impose any restrictions before main() is started, so +we have to adapt. + +Also, do not return error if there is an environment, but the +environment variable is not found. If uname() is called by kmod, then +the respective test will simply fail later. If it's something else +calling uname(), then we do not want to disturb the program. + +Patch-mainline: v17 +Git-commit: 632fb7b4634a540bb09af3b2004b3fe44cd4a214 +--- + testsuite/uname.c | 24 ++++++++++++++++-------- + 1 file changed, 16 insertions(+), 8 deletions(-) + +diff --git a/testsuite/uname.c b/testsuite/uname.c +index 2ada200..f55c435 100644 +--- a/testsuite/uname.c ++++ b/testsuite/uname.c +@@ -22,6 +22,7 @@ + #include + #include + #include ++#include + + #include "testsuite.h" + +@@ -29,17 +30,10 @@ TS_EXPORT int uname(struct utsname *u) + { + static void *nextlib = NULL; + static int (*nextlib_uname)(struct utsname *u); +- const char *release = getenv(S_TC_UNAME_R); ++ const char *release; + int err; + size_t sz; + +- if (release == NULL) { +- fprintf(stderr, "TRAP uname(): missing export %s?\n", +- S_TC_UNAME_R); +- errno = EFAULT; +- return -1; +- } +- + if (nextlib == NULL) { + #ifdef RTLD_NEXT + nextlib = RTLD_NEXT; +@@ -53,6 +47,20 @@ TS_EXPORT int uname(struct utsname *u) + if (err < 0) + return err; + ++ if (!environ) ++ /* ++ * probably called from within glibc before main(); unsafe ++ * to call getenv() ++ */ ++ return 0; ++ ++ release = getenv(S_TC_UNAME_R); ++ if (release == NULL) { ++ fprintf(stderr, "TRAP uname(): missing export %s?\n", ++ S_TC_UNAME_R); ++ return 0; ++ } ++ + sz = strlen(release) + 1; + if (sz > sizeof(u->release)) { + fprintf(stderr, "uname(): sizeof release (%s) " +-- +1.8.4.5 + diff --git a/kmod.changes b/kmod.changes index 7e1c20c..8f2759d 100644 --- a/kmod.changes +++ b/kmod.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri Mar 7 09:25:02 UTC 2014 - mmarek@suse.cz + +- testsuite: Fix uname() during glibc startup + ------------------------------------------------------------------- Wed Mar 5 14:50:34 UTC 2014 - mmarek@suse.cz diff --git a/kmod.spec b/kmod.spec index 6259db6..55c13b1 100644 --- a/kmod.spec +++ b/kmod.spec @@ -42,6 +42,7 @@ Patch7: 0007-Add-some-tests-for-kernels-without-finit_module-2.patch Patch8: 0008-libkmod-module-Simplify-kmod_module_insert_module.patch Patch9: 0009-libkmod-Implement-filtering-of-unsupported-modules-o.patch Patch10: 0010-modprobe-Implement-allow-unsupported-modules.patch +Patch11: 0001-testsuite-Fix-uname-during-glibc-startup.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: autoconf BuildRequires: automake @@ -122,6 +123,7 @@ touch man/rmmod.8 %patch8 -p1 %patch9 -p1 %patch10 -p1 +%patch11 -p1 %build autoreconf -fi From 8e0db140ab4db4d6def5ae0830f7628bc53a8209d95dcda1c51459b708cfd8a6 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Tue, 11 Mar 2014 14:01:20 +0000 Subject: [PATCH 3/6] Accepting request 225602 from home:michal-m:branches:Base:System - Provide and obsolete module-init-tools (bnc#867442) OBS-URL: https://build.opensuse.org/request/show/225602 OBS-URL: https://build.opensuse.org/package/show/Base:System/kmod?expand=0&rev=67 --- kmod.changes | 5 +++++ kmod.spec | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/kmod.changes b/kmod.changes index 8f2759d..eddc95b 100644 --- a/kmod.changes +++ b/kmod.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Tue Mar 11 13:38:23 UTC 2014 - mmarek@suse.cz + +- Provide and obsolete module-init-tools (bnc#867442) + ------------------------------------------------------------------- Fri Mar 7 09:25:02 UTC 2014 - mmarek@suse.cz diff --git a/kmod.spec b/kmod.spec index 55c13b1..0f378f4 100644 --- a/kmod.spec +++ b/kmod.spec @@ -77,8 +77,9 @@ Summary: Compat symlinks for kernel module utilities License: GPL-2.0+ Group: System/Kernel Requires: kmod +Obsoletes: module-init-tools < 3.16 +Provides: module-init-tools = 3.16 Provides: modutils -Conflicts: module-init-tools %description compat kmod is a set of tools to handle common tasks with Linux kernel From ccce001018d97d02147bac5c4f54b0cbf77cbbf48d8a05d36a5e505038aa2328 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Tue, 8 Apr 2014 08:48:24 +0000 Subject: [PATCH 4/6] Accepting request 229356 from home:michal-m:branches:Base:System - Remove th now obsolete test-files.tar.xz tarball (thanks to Jan Engelhardt) - Updated to kmod 17 - Do not require xsltproc for build - Parse softdeps stored in kernel modules - Add experimental python bindings (not enabled in the package yet) - Misc bugfixes - Deleted patches that went upstream. Only the unsupported modules feature remains: 0002-modprobe-Recognize-allow-unsupported-modules-on-comm.patch 0003-libkmod-config-Recognize-allow_unsupported_modules-i.patch 0009-libkmod-Implement-filtering-of-unsupported-modules-o.patch 0010-modprobe-Implement-allow-unsupported-modules.patch OBS-URL: https://build.opensuse.org/request/show/229356 OBS-URL: https://build.opensuse.org/package/show/Base:System/kmod?expand=0&rev=68 --- ...mod-w-documentation-and-getopt-entry.patch | 97 ------ ...suite-Fix-uname-during-glibc-startup.patch | 97 ------ ...the-list-of-loaded-modules-after-a-t.patch | 319 ------------------ ...estsuite-Add-test-for-modprobe-force.patch | 59 ---- ...-provide-finit_module-2-on-older-ker.patch | 67 ---- ...s-for-kernels-without-finit_module-2.patch | 79 ----- ...e-Simplify-kmod_module_insert_module.patch | 95 ------ kmod-16.tar.sign | 17 - kmod-16.tar.xz | 3 - kmod-17.tar.sign | 17 + kmod-17.tar.xz | 3 + kmod.changes | 22 ++ kmod.spec | 28 +- test-files.tar.xz | 3 - 14 files changed, 45 insertions(+), 861 deletions(-) delete mode 100644 0001-Remove-rmmod-w-documentation-and-getopt-entry.patch delete mode 100644 0001-testsuite-Fix-uname-during-glibc-startup.patch delete mode 100644 0004-testsuite-Check-the-list-of-loaded-modules-after-a-t.patch delete mode 100644 0005-testsuite-Add-test-for-modprobe-force.patch delete mode 100644 0006-testsuite-Do-not-provide-finit_module-2-on-older-ker.patch delete mode 100644 0007-Add-some-tests-for-kernels-without-finit_module-2.patch delete mode 100644 0008-libkmod-module-Simplify-kmod_module_insert_module.patch delete mode 100644 kmod-16.tar.sign delete mode 100644 kmod-16.tar.xz create mode 100644 kmod-17.tar.sign create mode 100644 kmod-17.tar.xz delete mode 100644 test-files.tar.xz diff --git a/0001-Remove-rmmod-w-documentation-and-getopt-entry.patch b/0001-Remove-rmmod-w-documentation-and-getopt-entry.patch deleted file mode 100644 index f3a53f4..0000000 --- a/0001-Remove-rmmod-w-documentation-and-getopt-entry.patch +++ /dev/null @@ -1,97 +0,0 @@ -From abf0e3b4ddb0c7348492309f8ccccdcafba91b2f Mon Sep 17 00:00:00 2001 -From: Stephen Kitt -Date: Sun, 26 Jan 2014 18:00:23 -0200 -Subject: [PATCH 01/10] Remove "rmmod -w" documentation and getopt entry - -This patch removes the cmdopts declaration and the documentation. They -were leftover from the -w removal. - -Patch-mainline: v17 -Git-commit: a4bd1441e5c7e8903a9ae065801d4f06f13d06e9 -[mmarek: regenerated man/rmmod.8] ---- - man/rmmod.8 | 12 +----------- - man/rmmod.xml | 17 ----------------- - tools/rmmod.c | 1 - - 3 files changed, 1 insertion(+), 29 deletions(-) - -diff --git a/man/rmmod.8 b/man/rmmod.8 -index cd97efa..e5d879a 100644 ---- a/man/rmmod.8 -+++ b/man/rmmod.8 -@@ -31,7 +31,7 @@ - rmmod \- Simple program to remove a module from the Linux Kernel - .SH "SYNOPSIS" - .HP \w'\fBrmmod\fR\ 'u --\fBrmmod\fR [\fB\-f\fR] [\fB\-w\fR] [\fB\-s\fR] [\fB\-v\fR] [\fImodulename\fR] -+\fBrmmod\fR [\fB\-f\fR] [\fB\-s\fR] [\fB\-v\fR] [\fImodulename\fR] - .SH "DESCRIPTION" - .PP - \fBrmmod\fR -@@ -55,16 +55,6 @@ This option can be extremely dangerous: it has no effect unless CONFIG_MODULE_FO - \fBlsmod\fR(8))\&. - .RE - .PP --\fB\-w\fR \fB\-\-wait\fR --.RS 4 --Normally, --\fBrmmod\fR --will refuse to unload modules which are in use\&. With this option, --\fBrmmod\fR --will isolate the module, and wait until the module is no longer used\&. Nothing new will be able to use the module, but it\*(Aqs up to you to make sure the current users eventually finish with it\&. See --\fBlsmod\fR(8)) for information on usage counts\&. --.RE --.PP - \fB\-s\fR, \fB\-\-syslog\fR - .RS 4 - Send errors to syslog instead of standard error\&. -diff --git a/man/rmmod.xml b/man/rmmod.xml -index 3605068..5023fb0 100644 ---- a/man/rmmod.xml -+++ b/man/rmmod.xml -@@ -39,7 +39,6 @@ - - rmmod - -- - - - modulename -@@ -94,22 +93,6 @@ - - - -- -- -- -- -- Normally, rmmod will refuse to unload modules -- which are in use. With this option, rmmod will -- isolate the module, and wait until the module is no longer used. -- Nothing new will be able to use the module, but it's up to you to -- make sure the current users eventually finish with it. See -- -- lsmod8 -- ) for information on usage counts. -- -- -- -- - - - -diff --git a/tools/rmmod.c b/tools/rmmod.c -index fd0fac5..df2f041 100644 ---- a/tools/rmmod.c -+++ b/tools/rmmod.c -@@ -40,7 +40,6 @@ static const struct option cmdopts[] = { - {"syslog", no_argument, 0, 's'}, - {"verbose", no_argument, 0, 'v'}, - {"version", no_argument, 0, 'V'}, -- {"wait", no_argument, 0, 'w'}, - {"help", no_argument, 0, 'h'}, - {NULL, 0, 0, 0} - }; --- -1.8.4.5 - diff --git a/0001-testsuite-Fix-uname-during-glibc-startup.patch b/0001-testsuite-Fix-uname-during-glibc-startup.patch deleted file mode 100644 index 5394057..0000000 --- a/0001-testsuite-Fix-uname-during-glibc-startup.patch +++ /dev/null @@ -1,97 +0,0 @@ -From 4d392fa63af7f3fd09fdb49120864af1404d1a25 Mon Sep 17 00:00:00 2001 -From: Michal Marek -Date: Thu, 6 Mar 2014 18:03:46 +0100 -Subject: [PATCH] testsuite: Fix uname() during glibc startup - -In a specific configuration (chroot with the linux32 personality), the -modprobe_install_cmd_loop test failed, because the bash process handling -the install command segfaulted. The backtrace showed a uname() call -during libpthread initialization, at which point the environ pointer -hadn't been initialized yet: - - Program terminated with signal SIGSEGV, Segmentation fault. - #0 0x080c1591 in getenv (name=, - name@entry=0xf775f850 "TESTSUITE_UNAME_R") at getenv.c:81 - 81 for (i = 0, len = strlen (name); environ[i]; i++) - (gdb) bt - #0 0x080c1591 in getenv (name=, - name@entry=0xf775f850 "TESTSUITE_UNAME_R") at getenv.c:81 - #1 0xf775f754 in uname (u=u@entry=0xff946350) at testsuite/uname.c:32 - #2 0xf74ffc6c in is_smp_system () - at ../nptl/sysdeps/unix/sysv/linux/i386/smp.h:39 - #3 __pthread_initialize_minimal_internal () at nptl-init.c:460 - #4 0xf74fe32c in _init () at ../sysdeps/i386/crti.S:74 - #5 0x00000000 in ?? () - (gdb) p environ - $1 = (char **) 0x0 - -I don't know why it only happend in the chroot, but glibc can call its -own functions and impose any restrictions before main() is started, so -we have to adapt. - -Also, do not return error if there is an environment, but the -environment variable is not found. If uname() is called by kmod, then -the respective test will simply fail later. If it's something else -calling uname(), then we do not want to disturb the program. - -Patch-mainline: v17 -Git-commit: 632fb7b4634a540bb09af3b2004b3fe44cd4a214 ---- - testsuite/uname.c | 24 ++++++++++++++++-------- - 1 file changed, 16 insertions(+), 8 deletions(-) - -diff --git a/testsuite/uname.c b/testsuite/uname.c -index 2ada200..f55c435 100644 ---- a/testsuite/uname.c -+++ b/testsuite/uname.c -@@ -22,6 +22,7 @@ - #include - #include - #include -+#include - - #include "testsuite.h" - -@@ -29,17 +30,10 @@ TS_EXPORT int uname(struct utsname *u) - { - static void *nextlib = NULL; - static int (*nextlib_uname)(struct utsname *u); -- const char *release = getenv(S_TC_UNAME_R); -+ const char *release; - int err; - size_t sz; - -- if (release == NULL) { -- fprintf(stderr, "TRAP uname(): missing export %s?\n", -- S_TC_UNAME_R); -- errno = EFAULT; -- return -1; -- } -- - if (nextlib == NULL) { - #ifdef RTLD_NEXT - nextlib = RTLD_NEXT; -@@ -53,6 +47,20 @@ TS_EXPORT int uname(struct utsname *u) - if (err < 0) - return err; - -+ if (!environ) -+ /* -+ * probably called from within glibc before main(); unsafe -+ * to call getenv() -+ */ -+ return 0; -+ -+ release = getenv(S_TC_UNAME_R); -+ if (release == NULL) { -+ fprintf(stderr, "TRAP uname(): missing export %s?\n", -+ S_TC_UNAME_R); -+ return 0; -+ } -+ - sz = strlen(release) + 1; - if (sz > sizeof(u->release)) { - fprintf(stderr, "uname(): sizeof release (%s) " --- -1.8.4.5 - diff --git a/0004-testsuite-Check-the-list-of-loaded-modules-after-a-t.patch b/0004-testsuite-Check-the-list-of-loaded-modules-after-a-t.patch deleted file mode 100644 index 9ac2182..0000000 --- a/0004-testsuite-Check-the-list-of-loaded-modules-after-a-t.patch +++ /dev/null @@ -1,319 +0,0 @@ -From 525e74c84547001548840f7a909350b366ed9b30 Mon Sep 17 00:00:00 2001 -From: Michal Marek -Date: Thu, 27 Feb 2014 22:23:31 +0100 -Subject: [PATCH 04/10] testsuite: Check the list of loaded modules after a - test - -Add a ->modules_loaded member to struct test, which is a comma-separated -list of modules that should be present after the test finishes. Both -missing and excess modules cause an error. - -Patch-mainline: v17 -Git-commit: 88ac40840f0d13aaca844bb7198c252178968878 ---- - testsuite/test-init.c | 1 + - testsuite/test-modprobe.c | 13 +++- - testsuite/testsuite.c | 189 +++++++++++++++++++++++++++++++++++++++++++++- - testsuite/testsuite.h | 2 + - 4 files changed, 199 insertions(+), 6 deletions(-) - -diff --git a/testsuite/test-init.c b/testsuite/test-init.c -index 63b6501..d2aa4bd 100644 ---- a/testsuite/test-init.c -+++ b/testsuite/test-init.c -@@ -74,6 +74,7 @@ static DEFINE_TEST(test_insert, - [TC_ROOTFS] = TESTSUITE_ROOTFS "test-init/", - [TC_INIT_MODULE_RETCODES] = "bla:1:20", - }, -+ .modules_loaded = "ext4", - .need_spawn = true); - - static noreturn int test_remove(const struct test *t) -diff --git a/testsuite/test-modprobe.c b/testsuite/test-modprobe.c -index 637d363..c3ef31e 100644 ---- a/testsuite/test-modprobe.c -+++ b/testsuite/test-modprobe.c -@@ -91,7 +91,9 @@ static DEFINE_TEST(modprobe_show_alias_to_none, - }, - .output = { - .out = TESTSUITE_ROOTFS "test-modprobe/show-depends/correct-psmouse.txt", -- }); -+ }, -+ .modules_loaded = "", -+ ); - - - static noreturn int modprobe_builtin(const struct test *t) -@@ -131,7 +133,9 @@ static DEFINE_TEST(modprobe_softdep_loop, - [TC_UNAME_R] = "4.4.4", - [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/softdep-loop", - [TC_INIT_MODULE_RETCODES] = "", -- }); -+ }, -+ .modules_loaded = "btusb,bluetooth", -+ ); - - static noreturn int modprobe_install_cmd_loop(const struct test *t) - { -@@ -156,6 +160,7 @@ static DEFINE_TEST(modprobe_install_cmd_loop, - { "MODPROBE", ABS_TOP_BUILDDIR "/tools/modprobe" }, - { } - }, -+ .modules_loaded = "snd,snd-pcm", - ); - - static noreturn int modprobe_param_kcmdline(const struct test *t) -@@ -178,7 +183,9 @@ static DEFINE_TEST(modprobe_param_kcmdline, - }, - .output = { - .out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline/correct.txt", -- }); -+ }, -+ .modules_loaded = "", -+ ); - - - static const struct test *tests[] = { -diff --git a/testsuite/testsuite.c b/testsuite/testsuite.c -index 9877a64..c29ca78 100644 ---- a/testsuite/testsuite.c -+++ b/testsuite/testsuite.c -@@ -20,6 +20,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -528,12 +529,189 @@ fail: - return true; - } - -+static int cmp_modnames(const void *m1, const void *m2) -+{ -+ const char *s1 = *(char *const *)m1; -+ const char *s2 = *(char *const *)m2; -+ int i; -+ -+ for (i = 0; s1[i] || s2[i]; i++) { -+ char c1 = s1[i], c2 = s2[i]; -+ if (c1 == '-') -+ c1 = '_'; -+ if (c2 == '-') -+ c2 = '_'; -+ if (c1 != c2) -+ return c1 - c2; -+ } -+ return 0; -+} -+ -+/* -+ * Store the expected module names in buf and return a list of pointers to -+ * them. -+ */ -+static const char **read_expected_modules(const struct test *t, -+ char **buf, int *count) -+{ -+ const char **res; -+ int len; -+ int i; -+ char *p; -+ -+ if (t->modules_loaded[0] == '\0') { -+ *count = 0; -+ *buf = NULL; -+ return NULL; -+ } -+ *buf = strdup(t->modules_loaded); -+ if (!*buf) { -+ *count = -1; -+ return NULL; -+ } -+ len = 1; -+ for (p = *buf; *p; p++) -+ if (*p == ',') -+ len++; -+ res = malloc(sizeof(char *) * len); -+ if (!res) { -+ perror("malloc"); -+ *count = -1; -+ free(*buf); -+ *buf = NULL; -+ return NULL; -+ } -+ i = 0; -+ res[i++] = *buf; -+ for (p = *buf; i < len; p++) -+ if (*p == ',') { -+ *p = '\0'; -+ res[i++] = p + 1; -+ } -+ *count = len; -+ return res; -+} -+ -+static char **read_loaded_modules(const struct test *t, char **buf, int *count) -+{ -+ char dirname[PATH_MAX]; -+ DIR *dir; -+ struct dirent *dirent; -+ int i; -+ int len = 0, bufsz; -+ char **res = NULL; -+ char *p; -+ const char *rootfs = t->config[TC_ROOTFS] ? t->config[TC_ROOTFS] : ""; -+ -+ /* Store the entries in /sys/module to res */ -+ if (snprintf(dirname, sizeof(dirname), "%s/sys/module", rootfs) -+ >= (int)sizeof(dirname)) { -+ ERR("rootfs path too long: %s\n", rootfs); -+ *buf = NULL; -+ len = -1; -+ goto out; -+ } -+ dir = opendir(dirname); -+ /* not an error, simply return empty list */ -+ if (!dir) { -+ *buf = NULL; -+ goto out; -+ } -+ bufsz = 0; -+ while ((dirent = readdir(dir))) { -+ if (dirent->d_name[0] == '.') -+ continue; -+ len++; -+ bufsz += strlen(dirent->d_name) + 1; -+ } -+ res = malloc(sizeof(char *) * len); -+ if (!res) { -+ perror("malloc"); -+ len = -1; -+ goto out_dir; -+ } -+ *buf = malloc(bufsz); -+ if (!*buf) { -+ perror("malloc"); -+ free(res); -+ res = NULL; -+ len = -1; -+ goto out_dir; -+ } -+ rewinddir(dir); -+ i = 0; -+ p = *buf; -+ while ((dirent = readdir(dir))) { -+ int size; -+ -+ if (dirent->d_name[0] == '.') -+ continue; -+ size = strlen(dirent->d_name) + 1; -+ memcpy(p, dirent->d_name, size); -+ res[i++] = p; -+ p += size; -+ } -+out_dir: -+ closedir(dir); -+out: -+ *count = len; -+ return res; -+} -+ -+static int check_loaded_modules(const struct test *t) -+{ -+ int l1, l2, i1, i2; -+ const char **a1; -+ char **a2; -+ char *buf1, *buf2; -+ int err = false; -+ -+ a1 = read_expected_modules(t, &buf1, &l1); -+ if (l1 < 0) -+ return err; -+ a2 = read_loaded_modules(t, &buf2, &l2); -+ if (l2 < 0) -+ goto out_a1; -+ qsort(a1, l1, sizeof(char *), cmp_modnames); -+ qsort(a2, l2, sizeof(char *), cmp_modnames); -+ i1 = i2 = 0; -+ err = true; -+ while (i1 < l1 || i2 < l2) { -+ int cmp; -+ -+ if (i1 >= l1) -+ cmp = 1; -+ else if (i2 >= l2) -+ cmp = -1; -+ else -+ cmp = cmp_modnames(&a1[i1], &a2[i2]); -+ if (cmp == 0) { -+ i1++; -+ i2++; -+ } else if (cmp < 0) { -+ err = false; -+ ERR("module %s not loaded\n", a1[i1]); -+ i1++; -+ } else { -+ err = false; -+ ERR("module %s is loaded but should not be \n", a2[i2]); -+ i2++; -+ } -+ } -+ free(a2); -+ free(buf2); -+out_a1: -+ free(a1); -+ free(buf1); -+ return err; -+} -+ - static inline int test_run_parent(const struct test *t, int fdout[2], - int fderr[2], int fdmonitor[2], pid_t child) - { - pid_t pid; - int err; -- bool matchout; -+ bool matchout, match_modules; - - /* Close write-fds */ - if (t->output.out != NULL) -@@ -578,16 +756,21 @@ static inline int test_run_parent(const struct test *t, int fdout[2], - - if (matchout) - matchout = check_generated_files(t); -+ if (t->modules_loaded) -+ match_modules = check_loaded_modules(t); -+ else -+ match_modules = true; - - if (t->expected_fail == false) { - if (err == 0) { -- if (matchout) -+ if (matchout && match_modules) - LOG("%sPASSED%s: %s\n", - ANSI_HIGHLIGHT_GREEN_ON, ANSI_HIGHLIGHT_OFF, - t->name); - else { -- ERR("%sFAILED%s: exit ok but outputs do not match: %s\n", -+ ERR("%sFAILED%s: exit ok but %s do not match: %s\n", - ANSI_HIGHLIGHT_RED_ON, ANSI_HIGHLIGHT_OFF, -+ matchout ? "loaded modules" : "outputs", - t->name); - err = EXIT_FAILURE; - } -diff --git a/testsuite/testsuite.h b/testsuite/testsuite.h -index 97183cd..f2a75e5 100644 ---- a/testsuite/testsuite.h -+++ b/testsuite/testsuite.h -@@ -95,6 +95,8 @@ struct test { - */ - const struct keyval *files; - } output; -+ /* comma-separated list of loaded modules at the end of the test */ -+ const char *modules_loaded; - testfunc func; - const char *config[_TC_LAST]; - const char *path; --- -1.8.4.5 - diff --git a/0005-testsuite-Add-test-for-modprobe-force.patch b/0005-testsuite-Add-test-for-modprobe-force.patch deleted file mode 100644 index 9fe5ae0..0000000 --- a/0005-testsuite-Add-test-for-modprobe-force.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 5b532fd9616ba2a750e25378152bad4c9a2e7c27 Mon Sep 17 00:00:00 2001 -From: Michal Marek -Date: Thu, 27 Feb 2014 22:34:24 +0100 -Subject: [PATCH 05/10] testsuite: Add test for modprobe --force - -There is no check if the correct flags are passed to finit_module, but -at least we cover the respective code path in kmod. - -Patch-mainline: v17 -Git-commit: 2ce5de0ae6c191920a4eeeab757ccfad092d9e0f -[mmarek: Dropped binary files from the patch] ---- - testsuite/test-modprobe.c | 23 +++++++++++++++++++++++ - 1 file changed, 23 insertions(+) - -diff --git a/testsuite/test-modprobe.c b/testsuite/test-modprobe.c -index c3ef31e..92348b0 100644 ---- a/testsuite/test-modprobe.c -+++ b/testsuite/test-modprobe.c -@@ -187,6 +187,28 @@ static DEFINE_TEST(modprobe_param_kcmdline, - .modules_loaded = "", - ); - -+static noreturn int modprobe_force(const struct test *t) -+{ -+ const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; -+ const char *const args[] = { -+ progname, -+ "--force", "psmouse", -+ NULL, -+ }; -+ -+ test_spawn_prog(progname, args); -+ exit(EXIT_FAILURE); -+} -+static DEFINE_TEST(modprobe_force, -+ .description = "check modprobe --force", -+ .config = { -+ [TC_UNAME_R] = "4.4.4", -+ [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/force", -+ [TC_INIT_MODULE_RETCODES] = "", -+ }, -+ .modules_loaded = "psmouse", -+ ); -+ - - static const struct test *tests[] = { - &smodprobe_show_depends, -@@ -196,6 +218,7 @@ static const struct test *tests[] = { - &smodprobe_softdep_loop, - &smodprobe_install_cmd_loop, - &smodprobe_param_kcmdline, -+ &smodprobe_force, - NULL, - }; - --- -1.8.4.5 - diff --git a/0006-testsuite-Do-not-provide-finit_module-2-on-older-ker.patch b/0006-testsuite-Do-not-provide-finit_module-2-on-older-ker.patch deleted file mode 100644 index 90e24f4..0000000 --- a/0006-testsuite-Do-not-provide-finit_module-2-on-older-ker.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 970b96f070b3f9ccd9c1850db44116a2b02da424 Mon Sep 17 00:00:00 2001 -From: Michal Marek -Date: Thu, 27 Feb 2014 23:31:33 +0100 -Subject: [PATCH 06/10] testsuite: Do not provide finit_module(2) on older - kernels - -If the test's uname -r is less that 3.8, return -ENOSYS from -finit_module(), so that the fallback is tested. - -Patch-mainline: v17 -Git-commit: 063086e038657de64f9980bc51954b0817fa8e6c ---- - testsuite/init_module.c | 24 ++++++++++++++++++++++++ - 1 file changed, 24 insertions(+) - -diff --git a/testsuite/init_module.c b/testsuite/init_module.c -index 42177e7..269a471 100644 ---- a/testsuite/init_module.c -+++ b/testsuite/init_module.c -@@ -37,6 +37,7 @@ - #include - #include - #include -+#include - #include - - /* kmod_elf_get_section() is not exported, we need the private header */ -@@ -280,6 +281,25 @@ long init_module(void *mem, unsigned long len, const char *args) - return err; - } - -+static int check_kernel_version(int major, int minor) -+{ -+ struct utsname u; -+ const char *p; -+ int maj = 0, min = 0; -+ -+ if (uname(&u) < 0) -+ return false; -+ for (p = u.release; *p >= '0' && *p <= '9'; p++) -+ maj = maj * 10 + *p - '0'; -+ if (*p == '.') -+ for (p++; *p >= '0' && *p <= '9'; p++) -+ min = min * 10 + *p - '0'; -+ if (maj > major || (maj == major && min >= minor)) -+ return true; -+ return false; -+} -+ -+ - TS_EXPORT int finit_module(const int fd, const char *args, const int flags); - - int finit_module(const int fd, const char *args, const int flags) -@@ -289,6 +309,10 @@ int finit_module(const int fd, const char *args, const int flags) - unsigned long len; - struct stat st; - -+ if (!check_kernel_version(3, 8)) { -+ errno = ENOSYS; -+ return -1; -+ } - if (fstat(fd, &st) < 0) - return -1; - --- -1.8.4.5 - diff --git a/0007-Add-some-tests-for-kernels-without-finit_module-2.patch b/0007-Add-some-tests-for-kernels-without-finit_module-2.patch deleted file mode 100644 index ccdf949..0000000 --- a/0007-Add-some-tests-for-kernels-without-finit_module-2.patch +++ /dev/null @@ -1,79 +0,0 @@ -From 9a23dec3269fad1c4f03f6b9b4ceccedc136d4e2 Mon Sep 17 00:00:00 2001 -From: Michal Marek -Date: Thu, 27 Feb 2014 23:33:38 +0100 -Subject: [PATCH 07/10] Add some tests for kernels without finit_module(2) - -Patch-mainline: v17 -Git-commit: be29c40e25b71d35708b9fad5772ebcd8e4685b3 -[mmarek: Dropped binary files from the patch] ---- - testsuite/test-modprobe.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 46 insertions(+) - -diff --git a/testsuite/test-modprobe.c b/testsuite/test-modprobe.c -index 92348b0..b675f48 100644 ---- a/testsuite/test-modprobe.c -+++ b/testsuite/test-modprobe.c -@@ -209,6 +209,50 @@ static DEFINE_TEST(modprobe_force, - .modules_loaded = "psmouse", - ); - -+static noreturn int modprobe_oldkernel(const struct test *t) -+{ -+ const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; -+ const char *const args[] = { -+ progname, -+ "psmouse", -+ NULL, -+ }; -+ -+ test_spawn_prog(progname, args); -+ exit(EXIT_FAILURE); -+} -+static DEFINE_TEST(modprobe_oldkernel, -+ .description = "check modprobe --force", -+ .config = { -+ [TC_UNAME_R] = "3.3.3", -+ [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/oldkernel", -+ [TC_INIT_MODULE_RETCODES] = "", -+ }, -+ .modules_loaded = "psmouse", -+ ); -+ -+static noreturn int modprobe_oldkernel_force(const struct test *t) -+{ -+ const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe"; -+ const char *const args[] = { -+ progname, -+ "--force", "psmouse", -+ NULL, -+ }; -+ -+ test_spawn_prog(progname, args); -+ exit(EXIT_FAILURE); -+} -+static DEFINE_TEST(modprobe_oldkernel_force, -+ .description = "check modprobe --force", -+ .config = { -+ [TC_UNAME_R] = "3.3.3", -+ [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/oldkernel-force", -+ [TC_INIT_MODULE_RETCODES] = "", -+ }, -+ .modules_loaded = "psmouse", -+ ); -+ - - static const struct test *tests[] = { - &smodprobe_show_depends, -@@ -219,6 +263,8 @@ static const struct test *tests[] = { - &smodprobe_install_cmd_loop, - &smodprobe_param_kcmdline, - &smodprobe_force, -+ &smodprobe_oldkernel, -+ &smodprobe_oldkernel_force, - NULL, - }; - --- -1.8.4.5 - diff --git a/0008-libkmod-module-Simplify-kmod_module_insert_module.patch b/0008-libkmod-module-Simplify-kmod_module_insert_module.patch deleted file mode 100644 index d92fb4b..0000000 --- a/0008-libkmod-module-Simplify-kmod_module_insert_module.patch +++ /dev/null @@ -1,95 +0,0 @@ -From 40926774b6153bfd7f0321b3226323958bc4d81d Mon Sep 17 00:00:00 2001 -From: Michal Marek -Date: Thu, 27 Feb 2014 11:32:22 +0100 -Subject: [PATCH 08/10] libkmod-module: Simplify kmod_module_insert_module() - -Store the file and elf pointer in the kmod_module structure and have it -freed together with the module. - -Patch-mainline: v17 -Git-commit: c2f4d85a9adea895958fc85b9b87ce95a7dc7774 ---- - libkmod/libkmod-module.c | 27 ++++++++++----------------- - 1 file changed, 10 insertions(+), 17 deletions(-) - -diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c -index 2f92e16..b94abd4 100644 ---- a/libkmod/libkmod-module.c -+++ b/libkmod/libkmod-module.c -@@ -791,8 +791,7 @@ KMOD_EXPORT int kmod_module_insert_module(struct kmod_module *mod, - int err; - const void *mem; - off_t size; -- struct kmod_file *file; -- struct kmod_elf *elf = NULL; -+ struct kmod_elf *elf; - const char *path; - const char *args = options ? options : ""; - -@@ -805,13 +804,13 @@ KMOD_EXPORT int kmod_module_insert_module(struct kmod_module *mod, - return -ENOSYS; - } - -- file = kmod_file_open(mod->ctx, path); -- if (file == NULL) { -+ mod->file = kmod_file_open(mod->ctx, path); -+ if (mod->file == NULL) { - err = -errno; - return err; - } - -- if (kmod_file_get_direct(file)) { -+ if (kmod_file_get_direct(mod->file)) { - unsigned int kernel_flags = 0; - - if (flags & KMOD_INSERT_FORCE_VERMAGIC) -@@ -819,19 +818,16 @@ KMOD_EXPORT int kmod_module_insert_module(struct kmod_module *mod, - if (flags & KMOD_INSERT_FORCE_MODVERSION) - kernel_flags |= MODULE_INIT_IGNORE_MODVERSIONS; - -- err = finit_module(kmod_file_get_fd(file), args, kernel_flags); -+ err = finit_module(kmod_file_get_fd(mod->file), args, kernel_flags); - if (err == 0 || errno != ENOSYS) - goto init_finished; - } - -- size = kmod_file_get_size(file); -- mem = kmod_file_get_contents(file); -- - if (flags & (KMOD_INSERT_FORCE_VERMAGIC | KMOD_INSERT_FORCE_MODVERSION)) { -- elf = kmod_elf_new(mem, size); -+ elf = kmod_file_get_elf(mod->file); - if (elf == NULL) { - err = -errno; -- goto elf_failed; -+ return err; - } - - if (flags & KMOD_INSERT_FORCE_MODVERSION) { -@@ -847,7 +843,10 @@ KMOD_EXPORT int kmod_module_insert_module(struct kmod_module *mod, - } - - mem = kmod_elf_get_memory(elf); -+ } else { -+ mem = kmod_file_get_contents(mod->file); - } -+ size = kmod_file_get_size(mod->file); - - err = init_module(mem, size, args); - init_finished: -@@ -855,12 +854,6 @@ init_finished: - err = -errno; - INFO(mod->ctx, "Failed to insert module '%s': %m\n", path); - } -- -- if (elf != NULL) -- kmod_elf_unref(elf); --elf_failed: -- kmod_file_unref(file); -- - return err; - } - --- -1.8.4.5 - diff --git a/kmod-16.tar.sign b/kmod-16.tar.sign deleted file mode 100644 index da1f38d..0000000 --- a/kmod-16.tar.sign +++ /dev/null @@ -1,17 +0,0 @@ ------BEGIN PGP SIGNATURE----- -Version: GnuPG v2.0.22 (GNU/Linux) - -iQIcBAABAgAGBQJSt12kAAoJEJuipaYwy+pT7LIQAJ1Yidwj1KUJJcBHu9u3R4er -8bIxU+NdblsKWOSU7kwoyhVg1O0TqGcVjX88cfgaYlamXMMdlRHMd4qLj8yW/X4B -8ktHoUfGWA4WmvMWWKce+dEjCdAknBv5Zkd1M7fMz1EMhM6qxbyhtAkuasUGUQYJ -0vz+TaldNYIiKmLB6xnOOx/vQzEdZQxAb78q8v7Vc9fYw/W8bs2QElBlSG2v+9Bk -N4VsiRGkrDv+1Fj5zfk+HwH/fl3R8YtzckBbg1dZGGGDyWgytK7ZeK8n3hZgGWD7 -GHFbZIqX0timLq+aDW4tvtjBQeq6jCkXZghyxYd71kgTWwKYLRF22LOvlhJsowcA -lrbTkSkL1w3hdiDNZ2mJyK+sBtbPFj4Gslb4if9iWrePDkItgVT7mt989QHoEOl6 -5UBqsgGpKl+c1iDfFtM5oOmmAbBUkCCjN2ubI67CtED70syFhKWPhedsqe8dkHit -tZMAvvnczsbvVnnqdUtAkpEkGF8Qm3gFdPQ2vFPN4SP7/MmU9rPHNUt5A3NfYFv7 -beE7qj5GiTqMOfnN8zFojjCjoL6HlwI3NlBdVDLHHL3wlAyu0q4VfYMYykPvpsKJ -iX1ijwl03ObKGWhVhRbiWaMV7FoMAynCFEUsMb/OuFwAkbYSHG+JqkdyMVhJxHfQ -fOPUdvotkb+tIF++Ujux -=Ja4i ------END PGP SIGNATURE----- diff --git a/kmod-16.tar.xz b/kmod-16.tar.xz deleted file mode 100644 index 09044e3..0000000 --- a/kmod-16.tar.xz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:63412efab37c70459ccef167556965c93fd4f56af5986cd3750542a684c613c5 -size 1440880 diff --git a/kmod-17.tar.sign b/kmod-17.tar.sign new file mode 100644 index 0000000..9f2dfe4 --- /dev/null +++ b/kmod-17.tar.sign @@ -0,0 +1,17 @@ +-----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----- diff --git a/kmod-17.tar.xz b/kmod-17.tar.xz new file mode 100644 index 0000000..6ee5849 --- /dev/null +++ b/kmod-17.tar.xz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3ba7470041de04ca88308f501901b574169cb517d3192397074611b3921a2dfa +size 1484336 diff --git a/kmod.changes b/kmod.changes index eddc95b..e1c394d 100644 --- a/kmod.changes +++ b/kmod.changes @@ -1,3 +1,25 @@ +------------------------------------------------------------------- +Tue Apr 8 08:36:22 UTC 2014 - mmarek@suse.cz + +- Remove th now obsolete test-files.tar.xz tarball + (thanks to Jan Engelhardt) + +------------------------------------------------------------------- +Mon Apr 7 19:07:17 UTC 2014 - mmarek@suse.com + +- Updated to kmod 17 + - Do not require xsltproc for build + - Parse softdeps stored in kernel modules + - Add experimental python bindings (not enabled in the package + yet) + - Misc bugfixes +- Deleted patches that went upstream. Only the unsupported modules + feature remains: + 0002-modprobe-Recognize-allow-unsupported-modules-on-comm.patch + 0003-libkmod-config-Recognize-allow_unsupported_modules-i.patch + 0009-libkmod-Implement-filtering-of-unsupported-modules-o.patch + 0010-modprobe-Implement-allow-unsupported-modules.patch + ------------------------------------------------------------------- Tue Mar 11 13:38:23 UTC 2014 - mmarek@suse.cz diff --git a/kmod.spec b/kmod.spec index 0f378f4..6da839b 100644 --- a/kmod.spec +++ b/kmod.spec @@ -21,7 +21,7 @@ Name: kmod Summary: Utilities to load modules into the kernel License: LGPL-2.1+ and GPL-2.0+ Group: System/Kernel -Version: 16 +Version: 17 Release: 0 Url: http://www.jonmasters.org/blog/2011/12/20/libkmod-replaces-module-init-tools/ #Announce: https://lwn.net/Articles/577962/ @@ -30,28 +30,14 @@ 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 -# Files that would have been added by patches 5 and 7 -Source3: test-files.tar.xz -Patch1: 0001-Remove-rmmod-w-documentation-and-getopt-entry.patch Patch2: 0002-modprobe-Recognize-allow-unsupported-modules-on-comm.patch Patch3: 0003-libkmod-config-Recognize-allow_unsupported_modules-i.patch -Patch4: 0004-testsuite-Check-the-list-of-loaded-modules-after-a-t.patch -Patch5: 0005-testsuite-Add-test-for-modprobe-force.patch -Patch6: 0006-testsuite-Do-not-provide-finit_module-2-on-older-ker.patch -Patch7: 0007-Add-some-tests-for-kernels-without-finit_module-2.patch -Patch8: 0008-libkmod-module-Simplify-kmod_module_insert_module.patch Patch9: 0009-libkmod-Implement-filtering-of-unsupported-modules-o.patch Patch10: 0010-modprobe-Implement-allow-unsupported-modules.patch -Patch11: 0001-testsuite-Fix-uname-during-glibc-startup.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: autoconf BuildRequires: automake BuildRequires: libtool -%if 0%{?suse_version} >= 1220 -BuildRequires: libxslt-tools -%else -BuildRequires: libxslt -%endif BuildRequires: pkgconfig >= 0.21 BuildRequires: xz %if 0%{?sles_version} @@ -112,19 +98,11 @@ in %lname. %prep %{?gpg_verify: xz -dk "%{S:0}"; %gpg_verify %{S:2}} -%setup -q -a 3 -%patch1 -p1 -touch man/rmmod.8 +%setup -q %patch2 -p1 %patch3 -p1 -%patch4 -p1 -%patch5 -p1 -%patch6 -p1 -%patch7 -p1 -%patch8 -p1 %patch9 -p1 %patch10 -p1 -%patch11 -p1 %build autoreconf -fi @@ -174,7 +152,7 @@ mkdir -p "$b"/{bin,sbin,%_lib}; ln -s "%_bindir/kmod" "$b/bin/"; %if "%_libdir" != "/%_lib" ln -s "%_libdir/libkmod.so.2" "$b/%_lib/"; -ln -s "%_libdir/libkmod.so.2.2.6" "$b/%_lib/"; +ln -s "%_libdir/libkmod.so.2.2.7" "$b/%_lib/"; %endif %check diff --git a/test-files.tar.xz b/test-files.tar.xz deleted file mode 100644 index 94e8b8f..0000000 --- a/test-files.tar.xz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:71f16a0d75d3c1cff13c6eb7bf490f4fa59020d4b11b8eed3a8635b020fa162a -size 26776 From bfb302083d315d148b43940f24a882a75490da39328078579a4cecfab1b96fa1 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Tue, 8 Apr 2014 08:49:21 +0000 Subject: [PATCH 5/6] Syntax changes to changelog. Plus I don't need more credit than I already have :) OBS-URL: https://build.opensuse.org/package/show/Base:System/kmod?expand=0&rev=69 --- kmod.changes | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/kmod.changes b/kmod.changes index e1c394d..68e7d73 100644 --- a/kmod.changes +++ b/kmod.changes @@ -1,18 +1,16 @@ ------------------------------------------------------------------- Tue Apr 8 08:36:22 UTC 2014 - mmarek@suse.cz -- Remove th now obsolete test-files.tar.xz tarball - (thanks to Jan Engelhardt) +- Remove the now obsolete test-files.tar.xz tarball ------------------------------------------------------------------- Mon Apr 7 19:07:17 UTC 2014 - mmarek@suse.com - Updated to kmod 17 - - Do not require xsltproc for build - - Parse softdeps stored in kernel modules - - Add experimental python bindings (not enabled in the package - yet) - - Misc bugfixes +* Do not require xsltproc for build +* Parse softdeps stored in kernel modules +* Add experimental python bindings (not enabled in the package yet) +* Misc bugfixes - Deleted patches that went upstream. Only the unsupported modules feature remains: 0002-modprobe-Recognize-allow-unsupported-modules-on-comm.patch From e3cebe6d9d1daa3f1473c5a103015d9ba7956c3ce02269453cb8f15b7dc52516 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Mon, 14 Apr 2014 08:00:19 +0000 Subject: [PATCH 6/6] Accepting request 229859 from home:matwey:beaglebone132 OBS-URL: https://build.opensuse.org/request/show/229859 OBS-URL: https://build.opensuse.org/package/show/Base:System/kmod?expand=0&rev=70 --- ...op-in-mod_count_all_dependencies-whe.patch | 76 +++++++++++++++++++ kmod.changes | 6 ++ kmod.spec | 2 + 3 files changed, 84 insertions(+) create mode 100644 0001-Fix-recursion-loop-in-mod_count_all_dependencies-whe.patch 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