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
This commit is contained in:
parent
02c6c7041b
commit
1e7a75843a
80
depmod-Prevent-module-dependency-files-corruption.patch
Normal file
80
depmod-Prevent-module-dependency-files-corruption.patch
Normal file
@ -0,0 +1,80 @@
|
||||
From c1858f5d0a88a39f37a9b3efdd83245740fcb87d Mon Sep 17 00:00:00 2001
|
||||
From: Michal Suchanek <msuchanek@suse.de>
|
||||
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 <msuchanek@suse.de>
|
||||
---
|
||||
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 <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
+#include <sys/time.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#include <shared/array.h>
|
||||
@@ -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
|
||||
|
@ -1,3 +1,21 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Dec 7 14:55:21 UTC 2018 - Michal Suchanek <msuchanek@suse.de>
|
||||
|
||||
- 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
|
||||
|
||||
|
@ -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
|
||||
|
@ -1,7 +1,14 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Dec 7 14:55:21 UTC 2018 - Michal Suchanek <msuchanek@suse.de>
|
||||
|
||||
- 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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user