commit
3278cd8e5d
@ -4,32 +4,23 @@ Date: Fri, 25 Jan 2019 17:03:05 +0000
|
||||
Subject: [PATCH] ok
|
||||
|
||||
Signed-off-by: guoxiaoqi <guoxiaoqi2@huawei.com>
|
||||
---
|
||||
tools/depmod.c | 7 ++++---
|
||||
1 file changed, 4 insertions(+), 3 deletions(-)
|
||||
---
|
||||
tools/depmod.c | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/tools/depmod.c b/tools/depmod.c
|
||||
index 989d907..f519679 100644
|
||||
index fbbce10..01db7ad 100644
|
||||
--- a/tools/depmod.c
|
||||
+++ b/tools/depmod.c
|
||||
@@ -2438,7 +2438,7 @@ static int depmod_output(struct depmod *depmod, FILE *out)
|
||||
r = itr->cb(depmod, fp);
|
||||
@@ -2529,6 +2529,7 @@ static int depmod_output(struct depmod *depmod, FILE *out)
|
||||
if (fp == out)
|
||||
continue;
|
||||
-
|
||||
|
||||
+ fsync(fileno(fp));
|
||||
ferr = ferror(fp) | fclose(fp);
|
||||
|
||||
if (r < 0) {
|
||||
@@ -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",
|
||||
@@ -2467,8 +2466,10 @@ static int depmod_output(struct depmod *depmod, FILE *out)
|
||||
@@ -2556,8 +2557,10 @@ static int depmod_output(struct depmod *depmod, FILE *out)
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,5 +33,5 @@ index 989d907..f519679 100644
|
||||
return err;
|
||||
}
|
||||
--
|
||||
1.8.3.1
|
||||
2.19.1
|
||||
|
||||
|
||||
@ -1,62 +0,0 @@
|
||||
From a06bacf500d56b72b5f9b121ebf7f6af9e3df185 Mon Sep 17 00:00:00 2001
|
||||
From: Michal Suchanek <msuchanek@suse.de>
|
||||
Date: Mon, 17 Dec 2018 23:46:28 +0100
|
||||
Subject: [PATCH 16/36] 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 <msuchanek@suse.de>
|
||||
---
|
||||
tools/depmod.c | 9 +++++++--
|
||||
1 file changed, 7 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/tools/depmod.c b/tools/depmod.c
|
||||
index 18c0d61..0f7e33c 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",
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
BIN
kmod-25.tar.xz
BIN
kmod-25.tar.xz
Binary file not shown.
BIN
kmod-27.tar.xz
Normal file
BIN
kmod-27.tar.xz
Normal file
Binary file not shown.
16
kmod.spec
16
kmod.spec
@ -1,6 +1,6 @@
|
||||
Name: kmod
|
||||
Version: 25
|
||||
Release: 6
|
||||
Version: 27
|
||||
Release: 1
|
||||
Summary: Kernel module management
|
||||
# GPLv2+ is used by programs, LGPLv2+ is used for libraries.
|
||||
License: GPLv2+ and LGPLv2+
|
||||
@ -10,10 +10,8 @@ Source1: weak-modules
|
||||
Source2: depmod.conf.dist
|
||||
|
||||
Patch9000: bugfix-kmod-20-8-depmod-Don-t-unlinkat-orig-depfile-and-add-fsync.patch
|
||||
Patch9001: libkmod-module-check-for-NULL-before-accessing-point.patch
|
||||
Patch9002: depmod-prevent-module-dependency-files-corruption-du.patch
|
||||
|
||||
BuildRequires: gcc chrpath zlib-devel xz-devel libxslt
|
||||
BuildRequires: gcc chrpath zlib-devel xz-devel libxslt openssl-devel
|
||||
|
||||
Provides: module-init-tools = 4.0-1
|
||||
Provides: /sbin/modprobe
|
||||
@ -50,7 +48,7 @@ developers to understand the kmod.
|
||||
%autosetup -n %{name}-%{version} -p1
|
||||
|
||||
%build
|
||||
%configure --with-zlib --with-xz
|
||||
%configure --with-openssl --with-zlib --with-xz
|
||||
%make_build
|
||||
|
||||
%install
|
||||
@ -106,6 +104,12 @@ install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/depmod.d/dist.conf
|
||||
%doc TODO NEWS README
|
||||
|
||||
%changelog
|
||||
* Fri Apr 17 2020 Wang Shuo<wangshuo47@huawei.com> - 27-1
|
||||
- Type:enhancement
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC: update kmod to 27
|
||||
|
||||
* Wed Feb 28 2020 Wang Shuo<wangshuo47@huawei.com> - 25-6
|
||||
- Type:enhancement
|
||||
- ID:NA
|
||||
|
||||
@ -1,126 +0,0 @@
|
||||
From c8f0623ad18194eedfcca69ccae1cbfe6cf5d2a8 Mon Sep 17 00:00:00 2001
|
||||
From: Luca Bruno <luca.bruno@coreos.com>
|
||||
Date: Wed, 7 Mar 2018 10:51:21 +0000
|
||||
Subject: [PATCH 04/36] libkmod-module: check for NULL before accessing
|
||||
pointers
|
||||
|
||||
This introduces a few missing NULL-checks in public functions, and
|
||||
align their docstrings with real behavior by getting rid of copy-paste
|
||||
mistakes.
|
||||
|
||||
Signed-off-by: Luca Bruno <luca.bruno@coreos.com>
|
||||
---
|
||||
TODO | 5 +++++
|
||||
libkmod/libkmod-module.c | 23 ++++++++++-------------
|
||||
2 files changed, 15 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/TODO b/TODO
|
||||
index 537e7e1..3fe06eb 100644
|
||||
--- a/TODO
|
||||
+++ b/TODO
|
||||
@@ -35,6 +35,11 @@ and libkmod
|
||||
- kmod_module_symbols_free_list()
|
||||
- kmod_module_dependency_symbols_free_list()
|
||||
|
||||
+* libkmod API breaking changes:
|
||||
+ - dedicated error value for all kmod_*_get_crc() functions. Currently there
|
||||
+ is no way for callers to distinguish between a valid CRC=0 and the error
|
||||
+ code 0.
|
||||
+
|
||||
* index: drop the "open(), seek(), read()" implementation and use another one
|
||||
with mmap(). When lookup() is called and the file is not mmaped, mmap it.
|
||||
Another possibility is to drop the mmap implementation relying on VFS to have
|
||||
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
|
||||
index 0a3ef11..ee420f4 100644
|
||||
--- a/libkmod/libkmod-module.c
|
||||
+++ b/libkmod/libkmod-module.c
|
||||
@@ -2519,7 +2519,7 @@ KMOD_EXPORT const char *kmod_module_version_get_symbol(const struct kmod_list *e
|
||||
{
|
||||
struct kmod_module_version *version;
|
||||
|
||||
- if (entry == NULL)
|
||||
+ if (entry == NULL || entry->data == NULL)
|
||||
return NULL;
|
||||
|
||||
version = entry->data;
|
||||
@@ -2532,14 +2532,13 @@ KMOD_EXPORT const char *kmod_module_version_get_symbol(const struct kmod_list *e
|
||||
*
|
||||
* Get the crc of a kmod module version.
|
||||
*
|
||||
- * Returns: the crc of this kmod module version on success or NULL on
|
||||
- * failure. The string is owned by the version, do not free it.
|
||||
+ * Returns: the crc of this kmod module version if available, otherwise default to 0.
|
||||
*/
|
||||
KMOD_EXPORT uint64_t kmod_module_version_get_crc(const struct kmod_list *entry)
|
||||
{
|
||||
struct kmod_module_version *version;
|
||||
|
||||
- if (entry == NULL)
|
||||
+ if (entry == NULL || entry->data == NULL)
|
||||
return 0;
|
||||
|
||||
version = entry->data;
|
||||
@@ -2660,7 +2659,7 @@ KMOD_EXPORT const char *kmod_module_symbol_get_symbol(const struct kmod_list *en
|
||||
{
|
||||
struct kmod_module_symbol *symbol;
|
||||
|
||||
- if (entry == NULL)
|
||||
+ if (entry == NULL || entry->data == NULL)
|
||||
return NULL;
|
||||
|
||||
symbol = entry->data;
|
||||
@@ -2673,14 +2672,13 @@ KMOD_EXPORT const char *kmod_module_symbol_get_symbol(const struct kmod_list *en
|
||||
*
|
||||
* Get the crc of a kmod module symbol.
|
||||
*
|
||||
- * Returns: the crc of this kmod module symbol on success or NULL on
|
||||
- * failure. The string is owned by the symbol, do not free it.
|
||||
+ * Returns: the crc of this kmod module symbol if available, otherwise default to 0.
|
||||
*/
|
||||
KMOD_EXPORT uint64_t kmod_module_symbol_get_crc(const struct kmod_list *entry)
|
||||
{
|
||||
struct kmod_module_symbol *symbol;
|
||||
|
||||
- if (entry == NULL)
|
||||
+ if (entry == NULL || entry->data == NULL)
|
||||
return 0;
|
||||
|
||||
symbol = entry->data;
|
||||
@@ -2806,7 +2804,7 @@ KMOD_EXPORT const char *kmod_module_dependency_symbol_get_symbol(const struct km
|
||||
{
|
||||
struct kmod_module_dependency_symbol *dependency_symbol;
|
||||
|
||||
- if (entry == NULL)
|
||||
+ if (entry == NULL || entry->data == NULL)
|
||||
return NULL;
|
||||
|
||||
dependency_symbol = entry->data;
|
||||
@@ -2819,14 +2817,13 @@ KMOD_EXPORT const char *kmod_module_dependency_symbol_get_symbol(const struct km
|
||||
*
|
||||
* Get the crc of a kmod module dependency_symbol.
|
||||
*
|
||||
- * Returns: the crc of this kmod module dependency_symbol on success or NULL on
|
||||
- * failure. The string is owned by the dependency_symbol, do not free it.
|
||||
+ * Returns: the crc of this kmod module dependency_symbol if available, otherwise default to 0.
|
||||
*/
|
||||
KMOD_EXPORT uint64_t kmod_module_dependency_symbol_get_crc(const struct kmod_list *entry)
|
||||
{
|
||||
struct kmod_module_dependency_symbol *dependency_symbol;
|
||||
|
||||
- if (entry == NULL)
|
||||
+ if (entry == NULL || entry->data == NULL)
|
||||
return 0;
|
||||
|
||||
dependency_symbol = entry->data;
|
||||
@@ -2846,7 +2843,7 @@ KMOD_EXPORT int kmod_module_dependency_symbol_get_bind(const struct kmod_list *e
|
||||
{
|
||||
struct kmod_module_dependency_symbol *dependency_symbol;
|
||||
|
||||
- if (entry == NULL)
|
||||
+ if (entry == NULL || entry->data == NULL)
|
||||
return 0;
|
||||
|
||||
dependency_symbol = entry->data;
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user