Hello community, here is the log from the commit of package kmod for openSUSE:Factory checked in at 2018-12-28 12:32:09 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/kmod (Old) and /work/SRC/openSUSE:Factory/.kmod.new.28833 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "kmod" Fri Dec 28 12:32:09 2018 rev:52 rq:659771 version:25 Changes: -------- --- /work/SRC/openSUSE:Factory/kmod/kmod-testsuite.changes 2018-04-16 12:43:26.373226487 +0200 +++ /work/SRC/openSUSE:Factory/.kmod.new.28833/kmod-testsuite.changes 2018-12-28 12:32:11.152094353 +0100 @@ -1,0 +2,19 @@ +Fri Dec 7 14:55:21 UTC 2018 - Michal Suchanek <msucha...@suse.de> + +- 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 + +------------------------------------------------------------------- +Wed Jul 18 08:51:06 UTC 2018 - jeng...@inai.de + +- Remove enum padding constants, add enum.patch. + +------------------------------------------------------------------- +Fri Jun 8 21:37:14 UTC 2018 - vlad.bota...@gmail.com + +- allow 'modprobe -c' print the status of "allow_unsupported_modules" option. + Add 0012-modprobe-print-unsupported-status.patch + +------------------------------------------------------------------- @@ -5 +24 @@ - + libkmod-signature-pkcs-7-fix-crash-when-signer-info-.patch + Add libkmod-signature-pkcs-7-fix-crash-when-signer-info-.patch --- /work/SRC/openSUSE:Factory/kmod/kmod.changes 2018-07-28 12:38:12.612173083 +0200 +++ /work/SRC/openSUSE:Factory/.kmod.new.28833/kmod.changes 2018-12-28 12:32:11.252094284 +0100 @@ -1,0 +2,8 @@ +Fri Dec 7 14:55:21 UTC 2018 - Michal Suchanek <msucha...@suse.de> + +- 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 + +------------------------------------------------------------------- @@ -4 +12 @@ -- Add enum.patch. +- Remove enum padding constants, add enum.patch. @@ -10 +18 @@ - + 0012-modprobe-print-unsupported-status.patch + Add 0012-modprobe-print-unsupported-status.patch @@ -16 +24 @@ - + libkmod-signature-pkcs-7-fix-crash-when-signer-info-.patch + Add libkmod-signature-pkcs-7-fix-crash-when-signer-info-.patch New: ---- depmod-Prevent-module-dependency-files-corruption-du.patch depmod-Prevent-module-dependency-files-missing-durin.patch depmod-shut-up-gcc-insufficinet-buffer-warning.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ kmod-testsuite.spec ++++++ --- /var/tmp/diff_new_pack.vmAVoX/_old 2018-12-28 12:32:11.736093949 +0100 +++ /var/tmp/diff_new_pack.vmAVoX/_new 2018-12-28 12:32:11.736093949 +0100 @@ -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,11 @@ 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-missing-durin.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 @@ -62,7 +67,7 @@ %prep %setup -q -n kmod-%version -%patch -P 0 -P 1 -P 2 -P 3 -P 4 -P 5 -P 6 -P 7 -p1 +%autopatch -p1 %build autoreconf -fi ++++++ kmod.spec ++++++ --- /var/tmp/diff_new_pack.vmAVoX/_old 2018-12-28 12:32:11.752093938 +0100 +++ /var/tmp/diff_new_pack.vmAVoX/_new 2018-12-28 12:32:11.756093935 +0100 @@ -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,9 @@ 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-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 @@ -110,8 +113,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 +%autosetup -p1 %build autoreconf -fi ++++++ depmod-Prevent-module-dependency-files-corruption-du.patch ++++++ >From a06bacf500d56b72b5f9b121ebf7f6af9e3df185 Mon Sep 17 00:00:00 2001 From: Michal Suchanek <msucha...@suse.de> 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 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 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 <msucha...@suse.de> --- tools/depmod.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/depmod.c b/tools/depmod.c index 18c0d61b2db3..0f7e33ccfd59 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -29,6 +29,7 @@ #include <string.h> #include <unistd.h> #include <sys/stat.h> +#include <sys/time.h> #include <sys/utsname.h> #include <shared/array.h> @@ -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); if (out != NULL) dfd = -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_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); fd = openat(dfd, tmp, flags, mode); if (fd < 0) { ERR("openat(%s, %s, %o, %o): %m\n", -- 2.19.2 ++++++ depmod-Prevent-module-dependency-files-missing-durin.patch ++++++ >From c2996b5fa880e81f63c25e80a4157b2239e32c5d Mon Sep 17 00:00:00 2001 From: Michal Suchanek <msucha...@suse.de> 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 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 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 <msucha...@suse.de> --- 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 ++++++ depmod-shut-up-gcc-insufficinet-buffer-warning.patch ++++++ >From 4a894aeaebf69166e6344d8a82c2600a1d4c0d08 Mon Sep 17 00:00:00 2001 From: Michal Suchanek <msucha...@suse.de> 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 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. [ Lucas: fix up coding style and closing fd on error path ] Signed-off-by: Michal Suchanek <msucha...@suse.de> --- tools/depmod.c | 54 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/tools/depmod.c b/tools/depmod.c index 0f7e33ccfd59..391afe9fe0a0 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -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) +{ + int fd, dfd; + FILE *ret; + + dfd = open(dname, O_RDONLY); + 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(fd); + } + } + 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 +1435,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 +2313,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