From 1e7a75843a21900ff4ee138d443d11510cf445295de0c639d1ea02b8681c2b52 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Fri, 7 Dec 2018 19:01:50 +0000 Subject: [PATCH 1/6] Accepting request 656092 from home:michals - Fix module dependency file corruption on parallel invocation (bsc#1118629). + depmod-Prevent-module-dependency-files-corruption-due-to-pa.patch - Remove enum padding constants + enum.patch. - allow 'modprobe -c' print the status of "allow_unsupported_modules" option. + 0012-modprobe-print-unsupported-status.patch - Fix module dependency file corruption on parallel invocation (bsc#1118629). + depmod-Prevent-module-dependency-files-corruption-due-to-pa.patch - Remove enum padding constants + enum.patch. OBS-URL: https://build.opensuse.org/request/show/656092 OBS-URL: https://build.opensuse.org/package/show/Base:System/kmod?expand=0&rev=150 --- ...t-module-dependency-files-corruption.patch | 80 +++++++++++++++++++ kmod-testsuite.changes | 18 +++++ kmod-testsuite.spec | 7 +- kmod.changes | 9 ++- kmod.spec | 5 +- 5 files changed, 114 insertions(+), 5 deletions(-) create mode 100644 depmod-Prevent-module-dependency-files-corruption.patch diff --git a/depmod-Prevent-module-dependency-files-corruption.patch b/depmod-Prevent-module-dependency-files-corruption.patch new file mode 100644 index 0000000..33484dd --- /dev/null +++ b/depmod-Prevent-module-dependency-files-corruption.patch @@ -0,0 +1,80 @@ +From c1858f5d0a88a39f37a9b3efdd83245740fcb87d Mon Sep 17 00:00:00 2001 +From: Michal Suchanek +Date: Fri, 7 Dec 2018 15:45:41 +0100 +Subject: [PATCH] depmod: Prevent module dependency files corruption due to + parallel invocation. + +Depmod does not use unique filename for temporary files. There is no +guarantee the user does not attempt to run mutiple depmod processes in +parallel. If that happens a temporary file might be created by +depmod(1st), truncated by depmod(2nd), and renamed to final name by +depmod(1st) resulting in corrupted file seen by user. + +Due to missing mkstempat() this is more complex than it should be. +Adding PID and random number to the filename should be reasonably +reliable. Adding O_EXCL as mkstemp does fails creating the file rather +than corrupting existing file. + +Also prevent dependency files missing. This happens because target files +are removed before renaming the temporary file. + +Signed-off-by: Michal Suchanek +--- + tools/depmod.c | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/tools/depmod.c b/tools/depmod.c +index 989d9077926c..5526ac892cf8 100644 +--- a/tools/depmod.c ++++ b/tools/depmod.c +@@ -29,6 +29,7 @@ + #include + #include + #include ++#include + #include + + #include +@@ -2398,6 +2399,10 @@ static int depmod_output(struct depmod *depmod, FILE *out) + }; + const char *dname = depmod->cfg->dirname; + int dfd, err = 0; ++ struct timeval tv; ++ ++ gettimeofday(&tv, NULL); ++ srand(tv.tv_sec); + + if (out != NULL) + dfd = -1; +@@ -2412,15 +2417,17 @@ static int depmod_output(struct depmod *depmod, FILE *out) + + for (itr = depfiles; itr->name != NULL; itr++) { + FILE *fp = out; +- char tmp[NAME_MAX] = ""; ++ char tmp[NAME_MAX + 1] = ""; + int r, ferr; + + if (fp == NULL) { +- int flags = O_CREAT | O_TRUNC | O_WRONLY; ++ int flags = O_CREAT | O_TRUNC | O_WRONLY | O_EXCL; + int mode = 0644; + int fd; + +- snprintf(tmp, sizeof(tmp), "%s.tmp", itr->name); ++ snprintf(tmp, sizeof(tmp), "%s.%i.%i", itr->name, getpid(), ++ rand()); ++ tmp[NAME_MAX] = 0; + fd = openat(dfd, tmp, flags, mode); + if (fd < 0) { + ERR("openat(%s, %s, %o, %o): %m\n", +@@ -2451,7 +2458,6 @@ static int depmod_output(struct depmod *depmod, FILE *out) + break; + } + +- unlinkat(dfd, itr->name, 0); + if (renameat(dfd, tmp, dfd, itr->name) != 0) { + err = -errno; + CRIT("renameat(%s, %s, %s, %s): %m\n", +-- +2.19.2 + diff --git a/kmod-testsuite.changes b/kmod-testsuite.changes index 6a9f1b4..34c1f5b 100644 --- a/kmod-testsuite.changes +++ b/kmod-testsuite.changes @@ -1,3 +1,21 @@ +------------------------------------------------------------------- +Fri Dec 7 14:55:21 UTC 2018 - Michal Suchanek + +- Fix module dependency file corruption on parallel invocation (bsc#1118629). + + depmod-Prevent-module-dependency-files-corruption-due-to-pa.patch + +------------------------------------------------------------------- +Wed Jul 18 08:51:06 UTC 2018 - jengelh@inai.de + +- Remove enum padding constants + + enum.patch. + +------------------------------------------------------------------- +Fri Jun 8 21:37:14 UTC 2018 - vlad.botanic@gmail.com + +- allow 'modprobe -c' print the status of "allow_unsupported_modules" option. + + 0012-modprobe-print-unsupported-status.patch + ------------------------------------------------------------------- Fri Apr 6 10:43:42 UTC 2018 - msuchanek@suse.com diff --git a/kmod-testsuite.spec b/kmod-testsuite.spec index 3dec895..711bd84 100644 --- a/kmod-testsuite.spec +++ b/kmod-testsuite.spec @@ -12,7 +12,7 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # @@ -38,6 +38,9 @@ Patch4: 0010-modprobe-Implement-allow-unsupported-modules.patch Patch5: 0011-Do-not-filter-unsupported-modules-when-running-a-van.patch Patch6: libkmod-signature-Fix-crash-when-module-signature-is.patch Patch7: libkmod-signature-pkcs-7-fix-crash-when-signer-info-.patch +Patch8: 0012-modprobe-print-unsupported-status.patch +Patch9: enum.patch +Patch10: depmod-Prevent-module-dependency-files-corruption.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: asn1c BuildRequires: autoconf @@ -62,7 +65,7 @@ buildloop with the kernel. %prep %setup -q -n kmod-%version -%patch -P 0 -P 1 -P 2 -P 3 -P 4 -P 5 -P 6 -P 7 -p1 +%patch -P 0 -P 1 -P 2 -P 3 -P 4 -P 5 -P 6 -P 7 -P 8 -P 9 -P 10 -p1 %build autoreconf -fi diff --git a/kmod.changes b/kmod.changes index fa6e1cf..3d0cd1a 100644 --- a/kmod.changes +++ b/kmod.changes @@ -1,7 +1,14 @@ +------------------------------------------------------------------- +Fri Dec 7 14:55:21 UTC 2018 - Michal Suchanek + +- Fix module dependency file corruption on parallel invocation (bsc#1118629). + + depmod-Prevent-module-dependency-files-corruption-due-to-pa.patch + ------------------------------------------------------------------- Wed Jul 18 08:51:06 UTC 2018 - jengelh@inai.de -- Add enum.patch. +- Remove enum padding constants + + enum.patch. ------------------------------------------------------------------- Fri Jun 8 21:37:14 UTC 2018 - vlad.botanic@gmail.com diff --git a/kmod.spec b/kmod.spec index a6e376e..ecfd1bb 100644 --- a/kmod.spec +++ b/kmod.spec @@ -12,7 +12,7 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # @@ -39,6 +39,7 @@ Patch6: libkmod-signature-Fix-crash-when-module-signature-is.patch Patch7: libkmod-signature-pkcs-7-fix-crash-when-signer-info-.patch Patch8: 0012-modprobe-print-unsupported-status.patch Patch9: enum.patch +Patch10: depmod-Prevent-module-dependency-files-corruption.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: asn1c BuildRequires: autoconf @@ -111,7 +112,7 @@ in %lname. %prep %setup -q -n kmod-%version -%patch -P 0 -P 1 -P 2 -P 3 -P 4 -P 5 -P 6 -P 7 -P 8 -P 9 -p1 +%patch -P 0 -P 1 -P 2 -P 3 -P 4 -P 5 -P 6 -P 7 -P 8 -P 9 -P 10 -p1 %build autoreconf -fi From b11f1a90d12ca7753c5490e151cc776fab3636a11b4a7fafc982a4a502eae807 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Fri, 7 Dec 2018 19:03:54 +0000 Subject: [PATCH 2/6] remove wrong attribution OBS-URL: https://build.opensuse.org/package/show/Base:System/kmod?expand=0&rev=151 --- kmod-testsuite.changes | 13 ++++--------- kmod.changes | 13 ++++--------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/kmod-testsuite.changes b/kmod-testsuite.changes index 34c1f5b..29a64a9 100644 --- a/kmod-testsuite.changes +++ b/kmod-testsuite.changes @@ -2,25 +2,20 @@ Fri Dec 7 14:55:21 UTC 2018 - Michal Suchanek - Fix module dependency file corruption on parallel invocation (bsc#1118629). - + depmod-Prevent-module-dependency-files-corruption-due-to-pa.patch - -------------------------------------------------------------------- -Wed Jul 18 08:51:06 UTC 2018 - jengelh@inai.de - -- Remove enum padding constants - + enum.patch. + Add depmod-Prevent-module-dependency-files-corruption-due-to-pa.patch +- Remove enum padding constants, add enum.patch. ------------------------------------------------------------------- Fri Jun 8 21:37:14 UTC 2018 - vlad.botanic@gmail.com - allow 'modprobe -c' print the status of "allow_unsupported_modules" option. - + 0012-modprobe-print-unsupported-status.patch + Add 0012-modprobe-print-unsupported-status.patch ------------------------------------------------------------------- Fri Apr 6 10:43:42 UTC 2018 - msuchanek@suse.com - Fix crash when PKCS#7 signer name is not present in signature (bsc#1088244) - + libkmod-signature-pkcs-7-fix-crash-when-signer-info-.patch + Add libkmod-signature-pkcs-7-fix-crash-when-signer-info-.patch ------------------------------------------------------------------- Fri Mar 16 13:08:14 CET 2018 - ro@suse.de diff --git a/kmod.changes b/kmod.changes index 3d0cd1a..ad8d42e 100644 --- a/kmod.changes +++ b/kmod.changes @@ -2,25 +2,20 @@ Fri Dec 7 14:55:21 UTC 2018 - Michal Suchanek - Fix module dependency file corruption on parallel invocation (bsc#1118629). - + depmod-Prevent-module-dependency-files-corruption-due-to-pa.patch - -------------------------------------------------------------------- -Wed Jul 18 08:51:06 UTC 2018 - jengelh@inai.de - -- Remove enum padding constants - + enum.patch. + Add depmod-Prevent-module-dependency-files-corruption-due-to-pa.patch +- Remove enum padding constants, add enum.patch. ------------------------------------------------------------------- Fri Jun 8 21:37:14 UTC 2018 - vlad.botanic@gmail.com - allow 'modprobe -c' print the status of "allow_unsupported_modules" option. - + 0012-modprobe-print-unsupported-status.patch + Add 0012-modprobe-print-unsupported-status.patch ------------------------------------------------------------------- Fri Apr 6 10:43:42 UTC 2018 - msuchanek@suse.com - Fix crash when PKCS#7 signer name is not present in signature (bsc#1088244) - + libkmod-signature-pkcs-7-fix-crash-when-signer-info-.patch + Add libkmod-signature-pkcs-7-fix-crash-when-signer-info-.patch ------------------------------------------------------------------- Fri Mar 16 13:08:14 CET 2018 - ro@suse.de From d748fd2e5def4ac7cc344802468c7f3c2debccf16f40f048dc2fd2e00fe37864 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Fri, 7 Dec 2018 19:15:18 +0000 Subject: [PATCH 3/6] OBS-URL: https://build.opensuse.org/package/show/Base:System/kmod?expand=0&rev=152 --- kmod.spec | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kmod.spec b/kmod.spec index ecfd1bb..b25ca4c 100644 --- a/kmod.spec +++ b/kmod.spec @@ -111,8 +111,7 @@ This package contains the development headers for the library found in %lname. %prep -%setup -q -n kmod-%version -%patch -P 0 -P 1 -P 2 -P 3 -P 4 -P 5 -P 6 -P 7 -P 8 -P 9 -P 10 -p1 +%autosetup -p1 %build autoreconf -fi From 38e2a9611a48b7c9ac77a86c09eda9a4501a53fd319f34e4afe85a803f5d06b8 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Mon, 10 Dec 2018 23:56:41 +0000 Subject: [PATCH 4/6] Accepting request 656939 from home:michals Refresh the parallel patch. OBS-URL: https://build.opensuse.org/request/show/656939 OBS-URL: https://build.opensuse.org/package/show/Base:System/kmod?expand=0&rev=153 --- ...odule-dependency-files-corruption-du.patch | 34 ++---- ...odule-dependency-files-missing-durin.patch | 33 ++++++ ...t-up-gcc-insufficinet-buffer-warning.patch | 107 ++++++++++++++++++ kmod-testsuite.changes | 4 + kmod-testsuite.spec | 6 +- kmod.changes | 4 + kmod.spec | 4 +- 7 files changed, 166 insertions(+), 26 deletions(-) rename depmod-Prevent-module-dependency-files-corruption.patch => depmod-Prevent-module-dependency-files-corruption-du.patch (62%) create mode 100644 depmod-Prevent-module-dependency-files-missing-durin.patch create mode 100644 depmod-shut-up-gcc-insufficinet-buffer-warning.patch diff --git a/depmod-Prevent-module-dependency-files-corruption.patch b/depmod-Prevent-module-dependency-files-corruption-du.patch similarity index 62% rename from depmod-Prevent-module-dependency-files-corruption.patch rename to depmod-Prevent-module-dependency-files-corruption-du.patch index 33484dd..9cc4607 100644 --- a/depmod-Prevent-module-dependency-files-corruption.patch +++ b/depmod-Prevent-module-dependency-files-corruption-du.patch @@ -1,4 +1,4 @@ -From c1858f5d0a88a39f37a9b3efdd83245740fcb87d Mon Sep 17 00:00:00 2001 +From ff3140310a52ba86af67b3676f542e11e1451bdc Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Fri, 7 Dec 2018 15:45:41 +0100 Subject: [PATCH] depmod: Prevent module dependency files corruption due to @@ -11,20 +11,17 @@ depmod(1st), truncated by depmod(2nd), and renamed to final name by depmod(1st) resulting in corrupted file seen by user. Due to missing mkstempat() this is more complex than it should be. -Adding PID and random number to the filename should be reasonably -reliable. Adding O_EXCL as mkstemp does fails creating the file rather -than corrupting existing file. - -Also prevent dependency files missing. This happens because target files -are removed before renaming the temporary file. +Adding PID and timestamp to the filename should be reasonably reliable. +Adding O_EXCL as mkstemp does fails creating the file rather than +corrupting existing file. Signed-off-by: Michal Suchanek --- - tools/depmod.c | 14 ++++++++++---- - 1 file changed, 10 insertions(+), 4 deletions(-) + tools/depmod.c | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/depmod.c b/tools/depmod.c -index 989d9077926c..5526ac892cf8 100644 +index 18c0d61b2db3..3b6d16e76160 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -29,6 +29,7 @@ @@ -35,18 +32,17 @@ index 989d9077926c..5526ac892cf8 100644 #include #include -@@ -2398,6 +2399,10 @@ static int depmod_output(struct depmod *depmod, FILE *out) +@@ -2398,6 +2399,9 @@ static int depmod_output(struct depmod *depmod, FILE *out) }; const char *dname = depmod->cfg->dirname; int dfd, err = 0; + struct timeval tv; + + gettimeofday(&tv, NULL); -+ srand(tv.tv_sec); if (out != NULL) dfd = -1; -@@ -2412,15 +2417,17 @@ static int depmod_output(struct depmod *depmod, FILE *out) +@@ -2412,15 +2416,17 @@ static int depmod_output(struct depmod *depmod, FILE *out) for (itr = depfiles; itr->name != NULL; itr++) { FILE *fp = out; @@ -61,20 +57,12 @@ index 989d9077926c..5526ac892cf8 100644 int fd; - snprintf(tmp, sizeof(tmp), "%s.tmp", itr->name); -+ snprintf(tmp, sizeof(tmp), "%s.%i.%i", itr->name, getpid(), -+ rand()); ++ snprintf(tmp, sizeof(tmp), "%s.%i.%li.%li", itr->name, getpid(), ++ tv.tv_usec, tv.tv_sec); + tmp[NAME_MAX] = 0; fd = openat(dfd, tmp, flags, mode); if (fd < 0) { ERR("openat(%s, %s, %o, %o): %m\n", -@@ -2451,7 +2458,6 @@ static int depmod_output(struct depmod *depmod, FILE *out) - break; - } - -- unlinkat(dfd, itr->name, 0); - if (renameat(dfd, tmp, dfd, itr->name) != 0) { - err = -errno; - CRIT("renameat(%s, %s, %s, %s): %m\n", -- 2.19.2 diff --git a/depmod-Prevent-module-dependency-files-missing-durin.patch b/depmod-Prevent-module-dependency-files-missing-durin.patch new file mode 100644 index 0000000..4216594 --- /dev/null +++ b/depmod-Prevent-module-dependency-files-missing-durin.patch @@ -0,0 +1,33 @@ +From 3a48513ff3b5ab0b19696bc4c0fabb351bd62afb Mon Sep 17 00:00:00 2001 +From: Michal Suchanek +Date: Mon, 10 Dec 2018 15:30:07 +0100 +Subject: [PATCH] depmod: Prevent module dependency files missing during depmod + invocation. + +Depmod deletes the module dependency files before moving the temporary +files in their place. This results in user seeing no dependency files +while they are updated. Remove the unlink call. The rename call should +suffice to move the newa file in place and remove unlink the old one. It +should also do both atomically so there is no window whn no dependency +file exists. + +Signed-off-by: Michal Suchanek +--- + tools/depmod.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/tools/depmod.c b/tools/depmod.c +index 989d9077926c..18c0d61b2db3 100644 +--- a/tools/depmod.c ++++ b/tools/depmod.c +@@ -2451,7 +2451,6 @@ static int depmod_output(struct depmod *depmod, FILE *out) + break; + } + +- unlinkat(dfd, itr->name, 0); + if (renameat(dfd, tmp, dfd, itr->name) != 0) { + err = -errno; + CRIT("renameat(%s, %s, %s, %s): %m\n", +-- +2.19.2 + diff --git a/depmod-shut-up-gcc-insufficinet-buffer-warning.patch b/depmod-shut-up-gcc-insufficinet-buffer-warning.patch new file mode 100644 index 0000000..0ec2544 --- /dev/null +++ b/depmod-shut-up-gcc-insufficinet-buffer-warning.patch @@ -0,0 +1,107 @@ +From af9a6e3754b6fa4e5cefb70aa6621b2f52ca94f1 Mon Sep 17 00:00:00 2001 +From: Michal Suchanek +Date: Mon, 10 Dec 2018 16:36:03 +0100 +Subject: [PATCH] depmod: shut up gcc insufficinet buffer warning. + +In a couple of places depmod concatenates the module directory and filename +with snprintf. This can technically overflow creating an unterminated string if +module directory name is long. Use openat instead as is done elsewhere in +depmod. This avoids the snprintf, the extra buffer on stack, and the gcc +warning. It may even fix a corner case when the module direcotry name is just +under PATH_MAX. + +Signed-off-by: Michal Suchanek +--- + tools/depmod.c | 51 ++++++++++++++++++++++++++++++++++---------------- + 1 file changed, 35 insertions(+), 16 deletions(-) + +diff --git a/tools/depmod.c b/tools/depmod.c +index 3b6d16e76160..6fca30a2f3e2 100644 +--- a/tools/depmod.c ++++ b/tools/depmod.c +@@ -1389,19 +1389,42 @@ static int depmod_modules_build_array(struct depmod *depmod) + return 0; + } + ++static FILE * dfdopen(const char * dname, const char * filename, int flags, const char * mode) ++ { ++ int fd, dfd; ++ FILE * ret; ++ ++ dfd = open(dname, flags); ++ if (dfd < 0) { ++ WRN("could not open directory %s: %m\n", dname); ++ return NULL; ++ } ++ ++ fd = openat(dfd, filename, flags); ++ if (fd < 0) { ++ WRN("could not open %s at %s: %m\n", filename, dname); ++ ret = NULL; ++ } else { ++ ret = fdopen(fd, mode); ++ if (!ret) ++ WRN("could not associate stream with %s: %m\n", filename); ++ } ++ close(dfd); ++ return ret; ++} ++ ++ ++ + static void depmod_modules_sort(struct depmod *depmod) + { +- char order_file[PATH_MAX], line[PATH_MAX]; ++ char line[PATH_MAX]; ++ const char * order_file = "modules.order"; + FILE *fp; + unsigned idx = 0, total = 0; + +- snprintf(order_file, sizeof(order_file), "%s/modules.order", +- depmod->cfg->dirname); +- fp = fopen(order_file, "r"); +- if (fp == NULL) { +- WRN("could not open %s: %m\n", order_file); ++ fp = dfdopen(depmod->cfg->dirname, order_file, O_RDONLY, "r"); ++ if (fp == NULL) + return; +- } + + while (fgets(line, sizeof(line), fp) != NULL) { + size_t len = strlen(line); +@@ -1409,8 +1432,8 @@ static void depmod_modules_sort(struct depmod *depmod) + if (len == 0) + continue; + if (line[len - 1] != '\n') { +- ERR("%s:%u corrupted line misses '\\n'\n", +- order_file, idx); ++ ERR("%s/%s:%u corrupted line misses '\\n'\n", ++ depmod->cfg->dirname, order_file, idx); + goto corrupted; + } + } +@@ -2287,18 +2310,14 @@ static int output_builtin_bin(struct depmod *depmod, FILE *out) + { + FILE *in; + struct index_node *idx; +- char infile[PATH_MAX], line[PATH_MAX], modname[PATH_MAX]; ++ char line[PATH_MAX], modname[PATH_MAX]; + + if (out == stdout) + return 0; + +- snprintf(infile, sizeof(infile), "%s/modules.builtin", +- depmod->cfg->dirname); +- in = fopen(infile, "r"); +- if (in == NULL) { +- WRN("could not open %s: %m\n", infile); ++ in = dfdopen(depmod->cfg->dirname, "modules.builtin", O_RDONLY, "r"); ++ if (in == NULL) + return 0; +- } + + idx = index_create(); + if (idx == NULL) { +-- +2.19.2 + diff --git a/kmod-testsuite.changes b/kmod-testsuite.changes index 29a64a9..5dc13de 100644 --- a/kmod-testsuite.changes +++ b/kmod-testsuite.changes @@ -3,6 +3,10 @@ Fri Dec 7 14:55:21 UTC 2018 - Michal Suchanek - Fix module dependency file corruption on parallel invocation (bsc#1118629). Add depmod-Prevent-module-dependency-files-corruption-due-to-pa.patch + +------------------------------------------------------------------- +Wed Jul 18 08:51:06 UTC 2018 - jengelh@inai.de + - Remove enum padding constants, add enum.patch. ------------------------------------------------------------------- diff --git a/kmod-testsuite.spec b/kmod-testsuite.spec index 711bd84..746db1e 100644 --- a/kmod-testsuite.spec +++ b/kmod-testsuite.spec @@ -40,7 +40,9 @@ Patch6: libkmod-signature-Fix-crash-when-module-signature-is.patch Patch7: libkmod-signature-pkcs-7-fix-crash-when-signer-info-.patch Patch8: 0012-modprobe-print-unsupported-status.patch Patch9: enum.patch -Patch10: depmod-Prevent-module-dependency-files-corruption.patch +Patch10: depmod-Prevent-module-dependency-files-missing-durin.patch +Patch11: depmod-shut-up-gcc-insufficinet-buffer-warning.patch +Patch12: depmod-Prevent-module-dependency-files-corruption-du.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: asn1c BuildRequires: autoconf @@ -65,7 +67,7 @@ buildloop with the kernel. %prep %setup -q -n kmod-%version -%patch -P 0 -P 1 -P 2 -P 3 -P 4 -P 5 -P 6 -P 7 -P 8 -P 9 -P 10 -p1 +%autopatch -p1 %build autoreconf -fi diff --git a/kmod.changes b/kmod.changes index ad8d42e..75de06f 100644 --- a/kmod.changes +++ b/kmod.changes @@ -3,6 +3,10 @@ Fri Dec 7 14:55:21 UTC 2018 - Michal Suchanek - Fix module dependency file corruption on parallel invocation (bsc#1118629). Add depmod-Prevent-module-dependency-files-corruption-due-to-pa.patch + +------------------------------------------------------------------- +Wed Jul 18 08:51:06 UTC 2018 - jengelh@inai.de + - Remove enum padding constants, add enum.patch. ------------------------------------------------------------------- diff --git a/kmod.spec b/kmod.spec index b25ca4c..0448998 100644 --- a/kmod.spec +++ b/kmod.spec @@ -39,7 +39,9 @@ Patch6: libkmod-signature-Fix-crash-when-module-signature-is.patch Patch7: libkmod-signature-pkcs-7-fix-crash-when-signer-info-.patch Patch8: 0012-modprobe-print-unsupported-status.patch Patch9: enum.patch -Patch10: depmod-Prevent-module-dependency-files-corruption.patch +Patch10: depmod-Prevent-module-dependency-files-missing-durin.patch +Patch11: depmod-shut-up-gcc-insufficinet-buffer-warning.patch +Patch12: depmod-Prevent-module-dependency-files-corruption-du.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: asn1c BuildRequires: autoconf From e6f19480115f5414e5758f9cdd5ea6bbd893395212e6679ce60934042f34930c Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Tue, 18 Dec 2018 22:55:28 +0000 Subject: [PATCH 5/6] Accepting request 659763 from home:michals Fix changelog: mention all patches. Refesh to upstream patch. * Add depmod-Prevent-module-dependency-files-corruption-du.patch * Add depmod-Prevent-module-dependency-files-missing-durin.patch * Add depmod-shut-up-gcc-insufficinet-buffer-warning.patch * Add depmod-Prevent-module-dependency-files-corruption-du.patch * Add depmod-Prevent-module-dependency-files-missing-durin.patch * Add depmod-shut-up-gcc-insufficinet-buffer-warning.patch OBS-URL: https://build.opensuse.org/request/show/659763 OBS-URL: https://build.opensuse.org/package/show/Base:System/kmod?expand=0&rev=154 --- ...odule-dependency-files-corruption-du.patch | 22 +++++------- ...odule-dependency-files-missing-durin.patch | 16 ++++----- ...t-up-gcc-insufficinet-buffer-warning.patch | 35 +++++++++++-------- kmod-testsuite.changes | 4 ++- kmod-testsuite.spec | 4 +-- kmod.changes | 4 ++- kmod.spec | 4 +-- 7 files changed, 46 insertions(+), 43 deletions(-) diff --git a/depmod-Prevent-module-dependency-files-corruption-du.patch b/depmod-Prevent-module-dependency-files-corruption-du.patch index 9cc4607..f9e153d 100644 --- a/depmod-Prevent-module-dependency-files-corruption-du.patch +++ b/depmod-Prevent-module-dependency-files-corruption-du.patch @@ -1,7 +1,7 @@ -From ff3140310a52ba86af67b3676f542e11e1451bdc Mon Sep 17 00:00:00 2001 +From a06bacf500d56b72b5f9b121ebf7f6af9e3df185 Mon Sep 17 00:00:00 2001 From: Michal Suchanek -Date: Fri, 7 Dec 2018 15:45:41 +0100 -Subject: [PATCH] depmod: Prevent module dependency files corruption due to +Date: Mon, 17 Dec 2018 23:46:28 +0100 +Subject: [PATCH] depmod: prevent module dependency files corruption due to parallel invocation. Depmod does not use unique filename for temporary files. There is no @@ -17,11 +17,11 @@ corrupting existing file. Signed-off-by: Michal Suchanek --- - tools/depmod.c | 12 +++++++++--- - 1 file changed, 9 insertions(+), 3 deletions(-) + tools/depmod.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/depmod.c b/tools/depmod.c -index 18c0d61b2db3..3b6d16e76160 100644 +index 18c0d61b2db3..0f7e33ccfd59 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -29,6 +29,7 @@ @@ -42,24 +42,18 @@ index 18c0d61b2db3..3b6d16e76160 100644 if (out != NULL) dfd = -1; -@@ -2412,15 +2416,17 @@ static int depmod_output(struct depmod *depmod, FILE *out) - - for (itr = depfiles; itr->name != NULL; itr++) { - FILE *fp = out; -- char tmp[NAME_MAX] = ""; -+ char tmp[NAME_MAX + 1] = ""; +@@ -2416,11 +2420,12 @@ static int depmod_output(struct depmod *depmod, FILE *out) int r, ferr; if (fp == NULL) { - int flags = O_CREAT | O_TRUNC | O_WRONLY; -+ int flags = O_CREAT | O_TRUNC | O_WRONLY | O_EXCL; ++ int flags = O_CREAT | O_EXCL | O_WRONLY; int mode = 0644; int fd; - snprintf(tmp, sizeof(tmp), "%s.tmp", itr->name); + snprintf(tmp, sizeof(tmp), "%s.%i.%li.%li", itr->name, getpid(), + tv.tv_usec, tv.tv_sec); -+ tmp[NAME_MAX] = 0; fd = openat(dfd, tmp, flags, mode); if (fd < 0) { ERR("openat(%s, %s, %o, %o): %m\n", diff --git a/depmod-Prevent-module-dependency-files-missing-durin.patch b/depmod-Prevent-module-dependency-files-missing-durin.patch index 4216594..4d1b449 100644 --- a/depmod-Prevent-module-dependency-files-missing-durin.patch +++ b/depmod-Prevent-module-dependency-files-missing-durin.patch @@ -1,15 +1,15 @@ -From 3a48513ff3b5ab0b19696bc4c0fabb351bd62afb Mon Sep 17 00:00:00 2001 +From c2996b5fa880e81f63c25e80a4157b2239e32c5d Mon Sep 17 00:00:00 2001 From: Michal Suchanek -Date: Mon, 10 Dec 2018 15:30:07 +0100 -Subject: [PATCH] depmod: Prevent module dependency files missing during depmod - invocation. +Date: Mon, 10 Dec 2018 22:29:32 +0100 +Subject: [PATCH] depmod: prevent module dependency files missing during depmod + invocation -Depmod deletes the module dependency files before moving the temporary +depmod deletes the module dependency files before moving the temporary files in their place. This results in user seeing no dependency files while they are updated. Remove the unlink call. The rename call should -suffice to move the newa file in place and remove unlink the old one. It -should also do both atomically so there is no window whn no dependency -file exists. +suffice to move the new file in place and unlink the old one. It should +also do both atomically so there is no window when no dependency file +exists. Signed-off-by: Michal Suchanek --- diff --git a/depmod-shut-up-gcc-insufficinet-buffer-warning.patch b/depmod-shut-up-gcc-insufficinet-buffer-warning.patch index 0ec2544..306ffb0 100644 --- a/depmod-shut-up-gcc-insufficinet-buffer-warning.patch +++ b/depmod-shut-up-gcc-insufficinet-buffer-warning.patch @@ -1,7 +1,7 @@ -From af9a6e3754b6fa4e5cefb70aa6621b2f52ca94f1 Mon Sep 17 00:00:00 2001 +From 4a894aeaebf69166e6344d8a82c2600a1d4c0d08 Mon Sep 17 00:00:00 2001 From: Michal Suchanek -Date: Mon, 10 Dec 2018 16:36:03 +0100 -Subject: [PATCH] depmod: shut up gcc insufficinet buffer warning. +Date: Mon, 10 Dec 2018 22:29:34 +0100 +Subject: [PATCH] depmod: shut up gcc insufficinet buffer warning In a couple of places depmod concatenates the module directory and filename with snprintf. This can technically overflow creating an unterminated string if @@ -10,25 +10,28 @@ depmod. This avoids the snprintf, the extra buffer on stack, and the gcc warning. It may even fix a corner case when the module direcotry name is just under PATH_MAX. +[ Lucas: fix up coding style and closing fd on error path ] + Signed-off-by: Michal Suchanek --- - tools/depmod.c | 51 ++++++++++++++++++++++++++++++++++---------------- - 1 file changed, 35 insertions(+), 16 deletions(-) + tools/depmod.c | 54 +++++++++++++++++++++++++++++++++++--------------- + 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/tools/depmod.c b/tools/depmod.c -index 3b6d16e76160..6fca30a2f3e2 100644 +index 0f7e33ccfd59..391afe9fe0a0 100644 --- a/tools/depmod.c +++ b/tools/depmod.c -@@ -1389,19 +1389,42 @@ static int depmod_modules_build_array(struct depmod *depmod) +@@ -1389,19 +1389,45 @@ static int depmod_modules_build_array(struct depmod *depmod) return 0; } -+static FILE * dfdopen(const char * dname, const char * filename, int flags, const char * mode) -+ { ++static FILE *dfdopen(const char *dname, const char *filename, int flags, ++ const char *mode) ++{ + int fd, dfd; -+ FILE * ret; ++ FILE *ret; + -+ dfd = open(dname, flags); ++ dfd = open(dname, O_RDONLY); + if (dfd < 0) { + WRN("could not open directory %s: %m\n", dname); + return NULL; @@ -40,8 +43,10 @@ index 3b6d16e76160..6fca30a2f3e2 100644 + ret = NULL; + } else { + ret = fdopen(fd, mode); -+ if (!ret) ++ if (!ret) { + WRN("could not associate stream with %s: %m\n", filename); ++ close(fd); ++ } + } + close(dfd); + return ret; @@ -53,7 +58,7 @@ index 3b6d16e76160..6fca30a2f3e2 100644 { - char order_file[PATH_MAX], line[PATH_MAX]; + char line[PATH_MAX]; -+ const char * order_file = "modules.order"; ++ const char *order_file = "modules.order"; FILE *fp; unsigned idx = 0, total = 0; @@ -69,7 +74,7 @@ index 3b6d16e76160..6fca30a2f3e2 100644 while (fgets(line, sizeof(line), fp) != NULL) { size_t len = strlen(line); -@@ -1409,8 +1432,8 @@ static void depmod_modules_sort(struct depmod *depmod) +@@ -1409,8 +1435,8 @@ static void depmod_modules_sort(struct depmod *depmod) if (len == 0) continue; if (line[len - 1] != '\n') { @@ -80,7 +85,7 @@ index 3b6d16e76160..6fca30a2f3e2 100644 goto corrupted; } } -@@ -2287,18 +2310,14 @@ static int output_builtin_bin(struct depmod *depmod, FILE *out) +@@ -2287,18 +2313,14 @@ static int output_builtin_bin(struct depmod *depmod, FILE *out) { FILE *in; struct index_node *idx; diff --git a/kmod-testsuite.changes b/kmod-testsuite.changes index 5dc13de..c360d67 100644 --- a/kmod-testsuite.changes +++ b/kmod-testsuite.changes @@ -2,7 +2,9 @@ Fri Dec 7 14:55:21 UTC 2018 - Michal Suchanek - Fix module dependency file corruption on parallel invocation (bsc#1118629). - Add depmod-Prevent-module-dependency-files-corruption-due-to-pa.patch + * Add depmod-Prevent-module-dependency-files-corruption-du.patch + * Add depmod-Prevent-module-dependency-files-missing-durin.patch + * Add depmod-shut-up-gcc-insufficinet-buffer-warning.patch ------------------------------------------------------------------- Wed Jul 18 08:51:06 UTC 2018 - jengelh@inai.de diff --git a/kmod-testsuite.spec b/kmod-testsuite.spec index 746db1e..eeb4fa6 100644 --- a/kmod-testsuite.spec +++ b/kmod-testsuite.spec @@ -41,8 +41,8 @@ Patch7: libkmod-signature-pkcs-7-fix-crash-when-signer-info-.patch Patch8: 0012-modprobe-print-unsupported-status.patch Patch9: enum.patch Patch10: depmod-Prevent-module-dependency-files-missing-durin.patch -Patch11: depmod-shut-up-gcc-insufficinet-buffer-warning.patch -Patch12: depmod-Prevent-module-dependency-files-corruption-du.patch +Patch11: depmod-Prevent-module-dependency-files-corruption-du.patch +Patch12: depmod-shut-up-gcc-insufficinet-buffer-warning.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: asn1c BuildRequires: autoconf diff --git a/kmod.changes b/kmod.changes index 75de06f..78cd0e0 100644 --- a/kmod.changes +++ b/kmod.changes @@ -2,7 +2,9 @@ Fri Dec 7 14:55:21 UTC 2018 - Michal Suchanek - Fix module dependency file corruption on parallel invocation (bsc#1118629). - Add depmod-Prevent-module-dependency-files-corruption-due-to-pa.patch + * Add depmod-Prevent-module-dependency-files-corruption-du.patch + * Add depmod-Prevent-module-dependency-files-missing-durin.patch + * Add depmod-shut-up-gcc-insufficinet-buffer-warning.patch ------------------------------------------------------------------- Wed Jul 18 08:51:06 UTC 2018 - jengelh@inai.de diff --git a/kmod.spec b/kmod.spec index 0448998..fa6591e 100644 --- a/kmod.spec +++ b/kmod.spec @@ -40,8 +40,8 @@ Patch7: libkmod-signature-pkcs-7-fix-crash-when-signer-info-.patch Patch8: 0012-modprobe-print-unsupported-status.patch Patch9: enum.patch Patch10: depmod-Prevent-module-dependency-files-missing-durin.patch -Patch11: depmod-shut-up-gcc-insufficinet-buffer-warning.patch -Patch12: depmod-Prevent-module-dependency-files-corruption-du.patch +Patch11: depmod-Prevent-module-dependency-files-corruption-du.patch +Patch12: depmod-shut-up-gcc-insufficinet-buffer-warning.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: asn1c BuildRequires: autoconf From 83d668919e25c2cdb0d73f0e96b39912db20e0d3a10ced5c28fbbff8a4dd9ef8 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Tue, 18 Dec 2018 22:55:54 +0000 Subject: [PATCH 6/6] fix syntax again OBS-URL: https://build.opensuse.org/package/show/Base:System/kmod?expand=0&rev=155 --- kmod-testsuite.changes | 6 +++--- kmod.changes | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/kmod-testsuite.changes b/kmod-testsuite.changes index c360d67..1d200e4 100644 --- a/kmod-testsuite.changes +++ b/kmod-testsuite.changes @@ -2,9 +2,9 @@ Fri Dec 7 14:55:21 UTC 2018 - Michal Suchanek - Fix module dependency file corruption on parallel invocation (bsc#1118629). - * Add depmod-Prevent-module-dependency-files-corruption-du.patch - * Add depmod-Prevent-module-dependency-files-missing-durin.patch - * Add depmod-shut-up-gcc-insufficinet-buffer-warning.patch +- Add depmod-Prevent-module-dependency-files-corruption-du.patch +- Add depmod-Prevent-module-dependency-files-missing-durin.patch +- Add depmod-shut-up-gcc-insufficinet-buffer-warning.patch ------------------------------------------------------------------- Wed Jul 18 08:51:06 UTC 2018 - jengelh@inai.de diff --git a/kmod.changes b/kmod.changes index 78cd0e0..43edbad 100644 --- a/kmod.changes +++ b/kmod.changes @@ -2,9 +2,9 @@ Fri Dec 7 14:55:21 UTC 2018 - Michal Suchanek - Fix module dependency file corruption on parallel invocation (bsc#1118629). - * Add depmod-Prevent-module-dependency-files-corruption-du.patch - * Add depmod-Prevent-module-dependency-files-missing-durin.patch - * Add depmod-shut-up-gcc-insufficinet-buffer-warning.patch +- Add depmod-Prevent-module-dependency-files-corruption-du.patch +- Add depmod-Prevent-module-dependency-files-missing-durin.patch +- Add depmod-shut-up-gcc-insufficinet-buffer-warning.patch ------------------------------------------------------------------- Wed Jul 18 08:51:06 UTC 2018 - jengelh@inai.de