!52 update verion to 29

From: @zhouwenpei
Reviewed-by: @liqingqing_1229
Signed-off-by: @liqingqing_1229
This commit is contained in:
openeuler-ci-bot 2021-12-03 06:26:13 +00:00 committed by Gitee
commit ecc98e321b
18 changed files with 10 additions and 566 deletions

View File

@ -1,44 +0,0 @@
From fa67110f896cdef67f42cbc2206ae2a8524acee6 Mon Sep 17 00:00:00 2001
From: Marco d'Itri <md@linux.it>
Date: Thu, 7 Jan 2021 20:17:48 -0800
Subject: [PATCH] Fix "modinfo -F always shows name for built-ins"
Conflict:NA
Reference:https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/commit/?id=fa67110f896cdef67f42cbc2206ae2a8524acee6
Bug reported by Ben Hutchings <ben@decadent.org.uk>:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=970871
Now that the kernel provides module information for potentially
modular code that's actually built-in, it's possible to query these
built-ins with "modinfo -F". However, this doesn't work quite right:
$ modinfo -Flicense e1000e
GPL v2
$ modinfo -Flicense bitrev
name: bitrev
GPL
---
tools/modinfo.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/modinfo.c b/tools/modinfo.c
index 0231bb0..f6a971f 100644
--- a/tools/modinfo.c
+++ b/tools/modinfo.c
@@ -178,7 +178,11 @@ static int modinfo_do(struct kmod_module *mod)
is_builtin = (filename == NULL);
if (is_builtin) {
- printf("%-16s%s%c", "name:", kmod_module_get_name(mod), separator);
+ if (field == NULL)
+ printf("%-16s%s%c", "name:",
+ kmod_module_get_name(mod), separator);
+ else if (field != NULL && streq(field, "name"))
+ printf("%s%c", kmod_module_get_name(mod), separator);
filename = "(builtin)";
}
--
2.23.0

View File

@ -1,57 +0,0 @@
From 53b30aeba2dedae9f5558f560231d9462e063dfc Mon Sep 17 00:00:00 2001
From: Lucas De Marchi <lucas.demarchi@intel.com>
Date: Thu, 5 Mar 2020 13:33:10 -0800
Subject: [PATCH] depmod: do not output .bin to stdout
reason:do not output .bin to stdout
Conflict:NA
Reference:https://lore.kernel.org/linux-modules/20200306075934.3104-1-lucas.demarchi@intel.com/T/#t
index_write() relies on fseek/ftell to manage the position to which we
are write and thus needs the file stream to support it.
Right now when trying to write the index to stdout we fail with:
depmod: tools/depmod.c:416: index_write: Assertion `initial_offset >= 0' failed.
Aborted (core dumped)
We have no interest in outputting our index to stdout, so just skip it
like is done with other indexes.
While at it, add/remove some newlines to improve readability.
Reported-by: Yanko Kaneti <yaneti@declera.com>
Fix: b866b2165ae6 ("Lookup aliases in the modules.builtin.modinfo")
---
tools/depmod.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/depmod.c b/tools/depmod.c
index fbbce10..875e314 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -2408,8 +2408,10 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out)
struct index_node *idx;
struct kmod_list *l, *builtin = NULL;
- idx = index_create();
+ if (out == stdout)
+ return 0;
+ idx = index_create();
if (idx == NULL) {
ret = -ENOMEM;
goto fail;
@@ -2456,7 +2458,9 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out)
if (count)
index_write(idx, out);
+
index_destroy(idx);
+
fail:
if (builtin)
kmod_module_unref_list(builtin);
--
2.23.0

View File

@ -1,56 +0,0 @@
From bd96d05256db2ff9a89dbe2e8bb6e26fcb800052 Mon Sep 17 00:00:00 2001
From: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Date: Sun, 29 Nov 2020 18:47:36 +0200
Subject: [PATCH] depmod: output_builtin_alias_bin: free idx on error path
reason:depmod: output_builtin_alias_bin free idx on error path
Conflict:NA
Reference:https://lore.kernel.org/linux-modules/20201129164737.135866-2-yauheni.kaliuta@redhat.com/T/#u
idx is allocated in the beginning but it's not freed if there is
a failure after the allocation.
Change the error path: return immediately if idx allocation fails
and then free it in both success and error path at the end.
Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
---
tools/depmod.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/tools/depmod.c b/tools/depmod.c
index 875e314..2c03dfe 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -2412,10 +2412,8 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out)
return 0;
idx = index_create();
- if (idx == NULL) {
- ret = -ENOMEM;
- goto fail;
- }
+ if (idx == NULL)
+ return -ENOMEM;
ret = kmod_module_get_builtin(depmod->ctx, &builtin);
if (ret < 0) {
@@ -2458,13 +2456,12 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out)
if (count)
index_write(idx, out);
-
- index_destroy(idx);
-
fail:
if (builtin)
kmod_module_unref_list(builtin);
+ index_destroy(idx);
+
return ret;
}
--
2.23.0

View File

@ -1,46 +0,0 @@
From d8d1d54051053d770643b59c3f5cf5608a17a0ce Mon Sep 17 00:00:00 2001
From: Lucas De Marchi <lucas.demarchi@intel.com>
Date: Mon, 9 Mar 2020 22:00:28 -0700
Subject: [PATCH] libkmod: allow modules.alias.builtin to be optional
---
libkmod/libkmod.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
index ab5c1e8..43423d6 100644
--- a/libkmod/libkmod.c
+++ b/libkmod/libkmod.c
@@ -855,8 +855,8 @@ KMOD_EXPORT int kmod_validate_resources(struct kmod_ctx *ctx)
*/
KMOD_EXPORT int kmod_load_resources(struct kmod_ctx *ctx)
{
+ int ret = 0;
size_t i;
- int ret;
if (ctx == NULL)
return -ENOENT;
@@ -874,8 +874,17 @@ KMOD_EXPORT int kmod_load_resources(struct kmod_ctx *ctx)
index_files[i].fn);
ret = index_mm_open(ctx, path, &ctx->indexes_stamp[i],
&ctx->indexes[i]);
- if (ret)
- break;
+
+ /*
+ * modules.builtin.alias are considered optional since it's
+ * recently added and older installations may not have it;
+ * we allow failing for any reason
+ */
+ if (ret) {
+ if (i != KMOD_INDEX_MODULES_BUILTIN_ALIAS)
+ break;
+ ret = 0;
+ }
}
if (ret)
--
2.19.1

View File

@ -1,36 +0,0 @@
From 39dd171623744ac390dadf487c5a3ebf0b69f2ca Mon Sep 17 00:00:00 2001
From: Seung-Woo Kim <sw0312.kim@samsung.com>
Date: Fri, 9 Apr 2021 18:44:23 +0900
Subject: [PATCH] libkmod-config: fix a memory leak when kmod_list_append()
fails
Conflict:NA
Reference:https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/commit/?id=39dd171623744ac390dadf487c5a3ebf0b69f2ca
From kmod_config_new(), when kmod_list_append() fails,
fix not list-appended kmod_config_path leak.
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
---
libkmod/libkmod-config.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libkmod/libkmod-config.c b/libkmod/libkmod-config.c
index 4fdd40f..e83621b 100644
--- a/libkmod/libkmod-config.c
+++ b/libkmod/libkmod-config.c
@@ -909,8 +909,10 @@ int kmod_config_new(struct kmod_ctx *ctx, struct kmod_config **p_config,
memcpy(cf->path, path, pathlen);
tmp = kmod_list_append(path_list, cf);
- if (tmp == NULL)
+ if (tmp == NULL) {
+ free(cf);
goto oom;
+ }
path_list = tmp;
}
--
2.23.0

View File

@ -1,32 +0,0 @@
From 1cab02ecf6ee2a0aa34f3615dfd99c59f7e04e90 Mon Sep 17 00:00:00 2001
From: Seung-Woo Kim <sw0312.kim@samsung.com>
Date: Tue, 13 Apr 2021 20:23:14 +0900
Subject: [PATCH] libkmod: fix an overflow with wrong modules.builtin.modinfo
Conflict:NA
Reference:https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/commit/?id=1cab02ecf6ee2a0aa34f3615dfd99c59f7e04e90
Fix a possbile overflow with exact PATH_MAX length modname
in wrong modules.builtin.modinfo.
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
---
libkmod/libkmod-builtin.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libkmod/libkmod-builtin.c b/libkmod/libkmod-builtin.c
index fc9a376..a75a542 100644
--- a/libkmod/libkmod-builtin.c
+++ b/libkmod/libkmod-builtin.c
@@ -246,7 +246,7 @@ bool kmod_builtin_iter_get_modname(struct kmod_builtin_iter *iter,
len = dot - line;
- if (len > PATH_MAX) {
+ if (len >= PATH_MAX) {
sv_errno = ENAMETOOLONG;
goto fail;
}
--
2.23.0

View File

@ -1,33 +0,0 @@
From 675410c3b3b1cf4523f02ab6e3128c39bd5d5101 Mon Sep 17 00:00:00 2001
From: Seung-Woo Kim <sw0312.kim@samsung.com>
Date: Tue, 13 Apr 2021 20:23:15 +0900
Subject: [PATCH] libkmod: fix possible double free with wrong
modules.builtin.modinfo
Conflict:NA
Reference:https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/commit/?id=675410c3b3b1cf4523f02ab6e3128c39bd5d5101
Fix double free for *modinfo with non '\0' terminated wrong
modules.builtin.modinfo, which is because EOF is minus value.
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
---
libkmod/libkmod-builtin.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libkmod/libkmod-builtin.c b/libkmod/libkmod-builtin.c
index a75a542..a002cb5 100644
--- a/libkmod/libkmod-builtin.c
+++ b/libkmod/libkmod-builtin.c
@@ -313,7 +313,7 @@ ssize_t kmod_builtin_get_modinfo(struct kmod_ctx *ctx, const char *modname,
while (offset < iter->next) {
offset = get_string(iter, pos, &line, &linesz);
if (offset <= 0) {
- count = (offset) ? -errno : -EOF;
+ count = (offset) ? -errno : -EINVAL;
free(*modinfo);
goto fail;
}
--
2.23.0

View File

@ -1,171 +0,0 @@
From 3bd7187ff549a2ef2441dcddabf382cc53cf6f22 Mon Sep 17 00:00:00 2001
From: Lucas De Marchi <lucas.demarchi@intel.com>
Date: Mon, 9 Mar 2020 22:00:27 -0700
Subject: [PATCH] libkmod: fix return error when opening index
When calling kmod_load_resources() we could end up getting a bogus
return value -ENOMEM due to several other reasons, like the index not
existing. Change index_mm_open() to propagate the failure reason so we
can take actions on it or return to the caller.
---
libkmod/libkmod-index.c | 31 +++++++++++++++++++------------
libkmod/libkmod-index.h | 4 ++--
libkmod/libkmod.c | 16 ++++++++--------
3 files changed, 29 insertions(+), 22 deletions(-)
diff --git a/libkmod/libkmod-index.c b/libkmod/libkmod-index.c
index 1f3351a..6a34c8d 100644
--- a/libkmod/libkmod-index.c
+++ b/libkmod/libkmod-index.c
@@ -611,7 +611,7 @@ struct index_value *index_searchwild(struct index_file *in, const char *key)
static const char _idx_empty_str[] = "";
struct index_mm {
- struct kmod_ctx *ctx;
+ const struct kmod_ctx *ctx;
void *mm;
uint32_t root_offset;
size_t size;
@@ -739,10 +739,10 @@ static void index_mm_free_node(struct index_mm_node *node)
free(node);
}
-struct index_mm *index_mm_open(struct kmod_ctx *ctx, const char *filename,
- unsigned long long *stamp)
+int index_mm_open(const struct kmod_ctx *ctx, const char *filename,
+ unsigned long long *stamp, struct index_mm **pidx)
{
- int fd;
+ int fd, err;
struct stat st;
struct index_mm *idx;
struct {
@@ -752,28 +752,32 @@ struct index_mm *index_mm_open(struct kmod_ctx *ctx, const char *filename,
} hdr;
void *p;
+ assert(pidx != NULL);
+
DBG(ctx, "file=%s\n", filename);
idx = malloc(sizeof(*idx));
if (idx == NULL) {
ERR(ctx, "malloc: %m\n");
- return NULL;
+ return -ENOMEM;
}
if ((fd = open(filename, O_RDONLY|O_CLOEXEC)) < 0) {
DBG(ctx, "open(%s, O_RDONLY|O_CLOEXEC): %m\n", filename);
+ err = -errno;
goto fail_open;
}
- if (fstat(fd, &st) < 0)
- goto fail_nommap;
- if ((size_t) st.st_size < sizeof(hdr))
+ if (fstat(fd, &st) < 0 || (size_t) st.st_size < sizeof(hdr)) {
+ err = -EINVAL;
goto fail_nommap;
+ }
- if ((idx->mm = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0))
- == MAP_FAILED) {
+ idx->mm = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+ if (idx->mm == MAP_FAILED) {
ERR(ctx, "mmap(NULL, %"PRIu64", PROT_READ, %d, MAP_PRIVATE, 0): %m\n",
st.st_size, fd);
+ err = -errno;
goto fail_nommap;
}
@@ -785,12 +789,14 @@ struct index_mm *index_mm_open(struct kmod_ctx *ctx, const char *filename,
if (hdr.magic != INDEX_MAGIC) {
ERR(ctx, "magic check fail: %x instead of %x\n", hdr.magic,
INDEX_MAGIC);
+ err = -EINVAL;
goto fail;
}
if (hdr.version >> 16 != INDEX_VERSION_MAJOR) {
ERR(ctx, "major version check fail: %u instead of %u\n",
hdr.version >> 16, INDEX_VERSION_MAJOR);
+ err = -EINVAL;
goto fail;
}
@@ -800,8 +806,9 @@ struct index_mm *index_mm_open(struct kmod_ctx *ctx, const char *filename,
close(fd);
*stamp = stat_mstamp(&st);
+ *pidx = idx;
- return idx;
+ return 0;
fail:
munmap(idx->mm, st.st_size);
@@ -809,7 +816,7 @@ fail_nommap:
close(fd);
fail_open:
free(idx);
- return NULL;
+ return err;
}
void index_mm_close(struct index_mm *idx)
diff --git a/libkmod/libkmod-index.h b/libkmod/libkmod-index.h
index 52aebac..db671b0 100644
--- a/libkmod/libkmod-index.h
+++ b/libkmod/libkmod-index.h
@@ -40,8 +40,8 @@ void index_values_free(struct index_value *values);
/* Implementation using mmap */
struct index_mm;
-struct index_mm *index_mm_open(struct kmod_ctx *ctx, const char *filename,
- unsigned long long *stamp);
+int index_mm_open(const struct kmod_ctx *ctx, const char *filename,
+ unsigned long long *stamp, struct index_mm **pidx);
void index_mm_close(struct index_mm *index);
char *index_mm_search(struct index_mm *idx, const char *key);
struct index_value *index_mm_searchwild(struct index_mm *idx, const char *key);
diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
index 39f58d9..ab5c1e8 100644
--- a/libkmod/libkmod.c
+++ b/libkmod/libkmod.c
@@ -856,6 +856,7 @@ KMOD_EXPORT int kmod_validate_resources(struct kmod_ctx *ctx)
KMOD_EXPORT int kmod_load_resources(struct kmod_ctx *ctx)
{
size_t i;
+ int ret;
if (ctx == NULL)
return -ENOENT;
@@ -871,17 +872,16 @@ KMOD_EXPORT int kmod_load_resources(struct kmod_ctx *ctx)
snprintf(path, sizeof(path), "%s/%s.bin", ctx->dirname,
index_files[i].fn);
- ctx->indexes[i] = index_mm_open(ctx, path,
- &ctx->indexes_stamp[i]);
- if (ctx->indexes[i] == NULL)
- goto fail;
+ ret = index_mm_open(ctx, path, &ctx->indexes_stamp[i],
+ &ctx->indexes[i]);
+ if (ret)
+ break;
}
- return 0;
+ if (ret)
+ kmod_unload_resources(ctx);
-fail:
- kmod_unload_resources(ctx);
- return -ENOMEM;
+ return ret;
}
/**
--
2.19.1

View File

@ -1,35 +0,0 @@
From 47807c4cfa5ffe1e5da27e3d3056d9b47ba998c5 Mon Sep 17 00:00:00 2001
From: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Date: Sun, 29 Nov 2020 18:47:35 +0200
Subject: [PATCH] libkmod: kmod_builtin_get_modinfo: free modinfo on error
reason:kmod_builtin_get_modinfo: free modinfo on error
Conflict:NA
Reference:https://lore.kernel.org/linux-modules/CAKi4VA+kaWfLZ_Ue-teaJAvDQjfM6G-WK3KmMWVinR-Zg6T64A@mail.gmail.com/T/#t
The function allocates array but on building it if get_string()
fails it returns the error leaving the array allocated. The caller
does not care about it in error case either.
Free it to fix memory leak.
Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
---
libkmod/libkmod-builtin.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libkmod/libkmod-builtin.c b/libkmod/libkmod-builtin.c
index aaec5dd..fc9a376 100644
--- a/libkmod/libkmod-builtin.c
+++ b/libkmod/libkmod-builtin.c
@@ -314,6 +314,7 @@ ssize_t kmod_builtin_get_modinfo(struct kmod_ctx *ctx, const char *modname,
offset = get_string(iter, pos, &line, &linesz);
if (offset <= 0) {
count = (offset) ? -errno : -EOF;
+ free(*modinfo);
goto fail;
}
--
2.23.0

View File

@ -1,38 +0,0 @@
From 95ed3e75365b4922f4d5f3e024a26fe230f3a315 Mon Sep 17 00:00:00 2001
From: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Date: Sun, 29 Nov 2020 18:47:37 +0200
Subject: [PATCH] libkmod: kmod_log_null: qualify ctx argument as const
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
kmod_log_null() does not change ctx (does nothing).
Fix warnings
In file included from libkmod/libkmod-index.c:33:
libkmod/libkmod-index.c: In function index_mm_open:
libkmod/libkmod-index.c:757:6: warning: passing argument 1 of kmod_log_null discards const qualifier from pointer target type [-Wdiscarded-qualifiers]
757 | DBG(ctx, "file=%s\n", filename);
Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
---
libkmod/libkmod-internal.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libkmod/libkmod-internal.h b/libkmod/libkmod-internal.h
index b22ac2a..398af9c 100644
--- a/libkmod/libkmod-internal.h
+++ b/libkmod/libkmod-internal.h
@@ -11,7 +11,7 @@
#include "libkmod.h"
static _always_inline_ _printf_format_(2, 3) void
- kmod_log_null(struct kmod_ctx *ctx, const char *format, ...) {}
+ kmod_log_null(const struct kmod_ctx *ctx, const char *format, ...) {}
#define kmod_log_cond(ctx, prio, arg...) \
do { \
--
2.23.0

Binary file not shown.

BIN
kmod-29.tar.xz Normal file

Binary file not shown.

View File

@ -1,6 +1,6 @@
Name: kmod
Version: 27
Release: 8
Version: 29
Release: 1
Summary: Kernel module management
# GPLv2+ is used by programs, LGPLv2+ is used for libraries.
License: GPLv2+ and LGPLv2+
@ -9,22 +9,11 @@ Source0: https://www.kernel.org/pub/linux/utils/kernel/kmod/%{name}-%{ver
Source1: weak-modules
Source2: depmod.conf.dist
Patch6000: backport-libkmod-fix-return-error-when-opening-index.patch
Patch6001: backport-libkmod-allow-modules.alias.builtin-to-be-optional.patch
Patch6002: backport-depmod-do-not-output-.bin-to-stdout.patch
Patch6003: backport-libkmod-kmod_builtin_get_modinfo-free-modinfo-on-err.patch
Patch6004: backport-depmod-output_builtin_alias_bin-free-idx-on-error-pa.patch
Patch6005: backport-libkmod-kmod_log_null-qualify-ctx-argument-as-const.patch
Patch6006: backport-Fix-modinfo-F-always-shows-name-for-built-ins.patch
Patch6007: backport-libkmod-config-fix-a-memory-leak-when-kmod_list_appe.patch
Patch6008: backport-libkmod-fix-an-overflow-with-wrong-modules.builtin.m.patch
Patch6009: backport-libkmod-fix-possible-double-free-with-wrong-modules.patch
Patch6010: backport-libkmod-module-check-new_from_name-return-value-in-g.patch
Patch9000: bugfix-kmod-20-8-depmod-Don-t-unlinkat-orig-depfile-and-add-fsync.patch
Patch9001: Module-replace-the-module-with-new-module.patch
Patch9002: Module-suspend-the-module-by-rmmod-r-option.patch
Patch9003: don-t-check-module-s-refcnt-when-rmmod-with-r.patch
Patch1: 0001-libkmod-module-check-new_from_name-return-value-in-g.patch
Patch2: 0002-kmod-20-8-depmod-Don-t-unlinkat-orig-depfile-and-add-fsync.patch
Patch3: 0003-Module-replace-the-module-with-new-module.patch
Patch4: 0004-Module-suspend-the-module-by-rmmod-r-option.patch
Patch5: 0005-don-t-check-module-s-refcnt-when-rmmod-with-r.patch
BuildRequires: gcc chrpath zlib-devel xz-devel libxslt openssl-devel
@ -119,6 +108,9 @@ install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/depmod.d/dist.conf
%doc TODO NEWS README
%changelog
* Fri Dec 3 2021 zhouwenpei <zhouwenpei1@huawei.com> - 29-1
- update kmod to 29
* Mon Nov 29 2021 Yang Yanchao <yangyanchao6@huawei.com> - 27-8
- kmod: don't check module's refcnt when rmmod with -r
Module: replace the module with new module