kmod: fix the patches

Signed-off-by: fu.lin <fulin10@huawei.com>
This commit is contained in:
fu.lin 2022-09-02 14:15:59 +08:00
parent 20aa184fc6
commit a986201570
7 changed files with 108 additions and 214 deletions

View File

@ -1,4 +1,4 @@
From 7b595d0319908149edb603c49da05f8d5904a8d3 Mon Sep 17 00:00:00 2001 From 0eac0869e201a08170cb2255b623eab9d78072f8 Mon Sep 17 00:00:00 2001
From: Jason Luan <luanjianhai@huawei.com> From: Jason Luan <luanjianhai@huawei.com>
Date: Wed, 16 Sep 2020 01:21:50 +0000 Date: Wed, 16 Sep 2020 01:21:50 +0000
Subject: [PATCH 1/2] Module: replace the module with new module Subject: [PATCH 1/2] Module: replace the module with new module
@ -12,10 +12,10 @@ Signed-off-by: fu.lin <fu.lin10@huawei.com>
4 files changed, 22 insertions(+), 1 deletion(-) 4 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 714ee21..a243672 100644 index 12d8ed1..fd9861a 100644
--- a/libkmod/libkmod-module.c --- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c +++ b/libkmod/libkmod-module.c
@@ -854,8 +854,11 @@ KMOD_EXPORT int kmod_module_insert_module(struct kmod_module *mod, @@ -911,8 +911,11 @@ KMOD_EXPORT int kmod_module_insert_module(struct kmod_module *mod,
kernel_flags |= MODULE_INIT_IGNORE_VERMAGIC; kernel_flags |= MODULE_INIT_IGNORE_VERMAGIC;
if (flags & KMOD_INSERT_FORCE_MODVERSION) if (flags & KMOD_INSERT_FORCE_MODVERSION)
kernel_flags |= MODULE_INIT_IGNORE_MODVERSIONS; kernel_flags |= MODULE_INIT_IGNORE_MODVERSIONS;
@ -28,10 +28,10 @@ index 714ee21..a243672 100644
goto init_finished; goto init_finished;
} }
diff --git a/libkmod/libkmod.h b/libkmod/libkmod.h diff --git a/libkmod/libkmod.h b/libkmod/libkmod.h
index 3cab2e5..241431e 100644 index 7251aa7..a56e5b4 100644
--- a/libkmod/libkmod.h --- a/libkmod/libkmod.h
+++ b/libkmod/libkmod.h +++ b/libkmod/libkmod.h
@@ -148,6 +148,9 @@ enum kmod_remove { @@ -153,6 +153,9 @@ enum kmod_remove {
enum kmod_insert { enum kmod_insert {
KMOD_INSERT_FORCE_VERMAGIC = 0x1, KMOD_INSERT_FORCE_VERMAGIC = 0x1,
KMOD_INSERT_FORCE_MODVERSION = 0x2, KMOD_INSERT_FORCE_MODVERSION = 0x2,
@ -41,7 +41,7 @@ index 3cab2e5..241431e 100644
}; };
/* Flags to kmod_module_probe_insert_module() */ /* Flags to kmod_module_probe_insert_module() */
@@ -159,6 +162,9 @@ enum kmod_probe { @@ -164,6 +167,9 @@ enum kmod_probe {
KMOD_PROBE_DRY_RUN = 0x00010, KMOD_PROBE_DRY_RUN = 0x00010,
KMOD_PROBE_FAIL_ON_LOADED = 0x00020, KMOD_PROBE_FAIL_ON_LOADED = 0x00020,
@ -104,5 +104,5 @@ index c422971..f0be196 100644
puts(PACKAGE " version " VERSION); puts(PACKAGE " version " VERSION);
puts(KMOD_FEATURES); puts(KMOD_FEATURES);
-- --
2.31.1 2.35.1

View File

@ -1,37 +0,0 @@
From 64541d6aad210879e104e4796beeef49d4311f6d Mon Sep 17 00:00:00 2001
From: Yauheni Kaliuta <ykaliuta@redhat.com>
Date: Tue, 8 Jun 2021 09:29:22 +0300
Subject: [PATCH] libkmod-module: check "new_from_name" return value in
get_builtin
Conflict:NA
Reference:https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/commit/?id=64541d6aad210879e104e4796beeef49d4311f6d
kmod_module_new_from_name() may fail and return error value. It is
handled properly across the code, but in this particular place the
check is missing.
Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com>
---
libkmod/libkmod-module.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index b6320cc..6e0ff1a 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -2912,7 +2912,10 @@ int kmod_module_get_builtin(struct kmod_ctx *ctx, struct kmod_list **list)
goto fail;
}
- kmod_module_new_from_name(ctx, modname, &mod);
+ err = kmod_module_new_from_name(ctx, modname, &mod);
+ if (err < 0)
+ goto fail;
+
kmod_module_set_builtin(mod, true);
*list = kmod_list_append(*list, mod);
--
2.23.0

View File

@ -1,4 +1,4 @@
From 6a31ae1b9bdd731ffa71c2aeb1ce13e979c194d1 Mon Sep 17 00:00:00 2001 From 3466b9698c4372ec81ed71384e1845898b7044d0 Mon Sep 17 00:00:00 2001
From: Ruidong Cao <caoruidong@huawei.com> From: Ruidong Cao <caoruidong@huawei.com>
Date: Fri, 25 Sep 2020 03:00:25 -0400 Date: Fri, 25 Sep 2020 03:00:25 -0400
Subject: [PATCH 2/2] Module: suspend the module by rmmod r option Subject: [PATCH 2/2] Module: suspend the module by rmmod r option
@ -13,10 +13,10 @@ Signed-off-by: fu.lin <fu.lin10@huawei.com>
4 files changed, 11 insertions(+), 3 deletions(-) 4 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index a243672..70b633f 100644 index fd9861a..96f462a 100644
--- a/libkmod/libkmod-module.c --- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c +++ b/libkmod/libkmod-module.c
@@ -790,7 +790,7 @@ KMOD_EXPORT int kmod_module_remove_module(struct kmod_module *mod, @@ -846,7 +846,7 @@ KMOD_EXPORT int kmod_module_remove_module(struct kmod_module *mod,
return -ENOENT; return -ENOENT;
/* Filter out other flags and force ONONBLOCK */ /* Filter out other flags and force ONONBLOCK */
@ -26,13 +26,13 @@ index a243672..70b633f 100644
err = delete_module(mod->name, flags); err = delete_module(mod->name, flags);
diff --git a/libkmod/libkmod.h b/libkmod/libkmod.h diff --git a/libkmod/libkmod.h b/libkmod/libkmod.h
index 241431e..bcdefc4 100644 index a56e5b4..78d11b3 100644
--- a/libkmod/libkmod.h --- a/libkmod/libkmod.h
+++ b/libkmod/libkmod.h +++ b/libkmod/libkmod.h
@@ -142,6 +142,9 @@ struct kmod_module *kmod_module_get_module(const struct kmod_list *entry); @@ -147,6 +147,9 @@ enum kmod_remove {
enum kmod_remove {
KMOD_REMOVE_FORCE = O_TRUNC,
KMOD_REMOVE_NOWAIT = O_NONBLOCK, /* always set */ KMOD_REMOVE_NOWAIT = O_NONBLOCK, /* always set */
/* libkmod-only defines, not passed to kernel */
KMOD_REMOVE_NOLOG = 1,
+ +
+ /* custom flag */ + /* custom flag */
+ KMOD_REMOVE_REPLACE = 0x1000, + KMOD_REMOVE_REPLACE = 0x1000,
@ -87,5 +87,5 @@ index 3942e7b..1278234 100644
use_syslog = 1; use_syslog = 1;
break; break;
-- --
2.31.1 2.35.1

View File

@ -1,31 +0,0 @@
From e48b7f950e8a6c8b6ba825a14a5aeb8a5064cdfc Mon Sep 17 00:00:00 2001
From: Liu Chao <liuchao173@huawei.com>
Date: Mon, 7 Jun 2021 06:46:49 +0000
Subject: [PATCH] kmod: don't check module's refcnt when rmmod with -r
When we remove module that only kernel livepatches depend on it by
remmod -r, we want to only invoke resume function. But kmod will check
refcnt first, if refcnt is more than zero, kmod won't call kernel's
delete_module.
Signed-off-by: Liu Chao <liuchao173@huawei.com>
---
tools/rmmod.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/rmmod.c b/tools/rmmod.c
index 1278234..1d8d20b 100644
--- a/tools/rmmod.c
+++ b/tools/rmmod.c
@@ -178,7 +178,7 @@ static int do_rmmod(int argc, char *argv[])
break;
}
- if (!(flags & KMOD_REMOVE_FORCE) && check_module_inuse(mod) < 0) {
+ if (!(flags & KMOD_REMOVE_FORCE) && !(flags & KMOD_REMOVE_REPLACE) && check_module_inuse(mod) < 0) {
r++;
goto next;
}
--
2.23.0

View File

@ -1,44 +0,0 @@
From 9cf5b4af477347bb0f9ed51c28742c6baf62302b Mon Sep 17 00:00:00 2001
From: luhuaxin <luhuaxin1@huawei.com>
Date: Wed, 29 Jun 2022 14:33:30 +0800
Subject: [PATCH] Support to display sm3 sig_hashalgo
Signed-off-by: luhuaxin <luhuaxin1@huawei.com>
---
libkmod/libkmod-signature.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/libkmod/libkmod-signature.c b/libkmod/libkmod-signature.c
index 4e8748c..142570b 100644
--- a/libkmod/libkmod-signature.c
+++ b/libkmod/libkmod-signature.c
@@ -56,6 +56,7 @@ enum pkey_hash_algo {
PKEY_HASH_SHA384,
PKEY_HASH_SHA512,
PKEY_HASH_SHA224,
+ PKEY_HASH_SM3,
PKEY_HASH__LAST
};
@@ -68,6 +69,7 @@ const char *const pkey_hash_algo[PKEY_HASH__LAST] = {
[PKEY_HASH_SHA384] = "sha384",
[PKEY_HASH_SHA512] = "sha512",
[PKEY_HASH_SHA224] = "sha224",
+ [PKEY_HASH_SM3] = "sm3",
};
enum pkey_id_type {
@@ -161,6 +163,10 @@ static int obj_to_hash_algo(const ASN1_OBJECT *o)
return PKEY_HASH_SHA512;
case NID_sha224:
return PKEY_HASH_SHA224;
+# ifndef OPENSSL_NO_SM3
+ case NID_sm3:
+ return PKEY_HASH_SM3;
+# endif
default:
return -1;
}
--
1.8.3.1

90
kmod.changes Normal file
View File

@ -0,0 +1,90 @@
%changelog
* Fri Sep 02 2022 fu.lin <fulin10@huawei.com> - 30-2
- fit the old patch
* Tue Jul 26 2022 Qingqing Li <liqingqing3@huawei.com> - 30-1
- upgrade to kmod-30
* Wed Jun 29 2022 luhuaxin <luhuaxin1@huawei.com> - 29-5
- support to display sm3 sig_hashalgo
* Thu Feb 24 2022 Yang Yanchao <yangyanchao6@huawei.com> - 29-4
- add package python3-kmod.
* Fri Jan 7 2022 zhouwenpei <zhouwenpei1@huawei.com> - 29-3
- kmod-devel: add requires on kmod-libs
* Thu Dec 9 2021 Jiangfeng Xiao <xiaojiangfeng@huawei.com> - 29-2
- kmod: revert "depmod: Do not unlinkat orig depfile and add fync"
* 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
Module: suspend the module by rmmod r option
* Wed Nov 24 2021 Yang Yanchao <yangyanchao6@huawei.com> - 27-7
- Precisely filters ko files in "/lib/modules/$kernel/extra"
to avoid creating unnecessary symbols.
* Tue Nov 9 2021 Yang Yanchao <yangyanchao6@huawei.com> - 27-6
- Sync the weak-modules script from the 20.03-LTS-SP1
- use -V to sort kernel version in weak-modules
* Fri Jun 18 2021 hushiyuan <hushiyuan@huawei.com> - 27-5
- libkmod-module: check "new_from_name" return value in get_builtin
- libkmod:fix double free for modinfo in modules.buildin.modinfo
- libkmod:fix an overflow with wrong modules.builtin.modinfo
- libkmod-config:fix a memory leak when kmod_list_append failes
- Fix "modinfo -F always shows name for build-ins"
* Thu Jan 14 2021 xinghe <xinghe1@huawei.com> - 27-4
- fix memory leak in kmodinfo and build warning
* Fri Sep 04 2020 xinghe <xinghe1@huawei.com> - 27-3
- backport patch to deal with lspci -v error report
* Fri Aug 21 2020 Wang Shuo<wangshuo_1994@foxmail.com> - 27-2
- remove unnecessary message
* Fri Apr 17 2020 Wang Shuo<wangshuo47@huawei.com> - 27-1
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: update kmod to 27
* Wed Feb 26 2020 Wang Shuo<wangshuo47@huawei.com> - 25-6
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: move libs files to libs package
* Sat Apr 6 2019 luochunsheng<luochunsheng@huawei.com> - 25-5
- Type:enhancement
- ID:NA
- SUG:NA
* Fri Mar 22 2019 kangenbo<kangenbo@huawei.com> - 25-4
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: backport patches from communities
* Tue Mar 19 2019 hexiaowen<hexiaowen@huawei.com> - 25-3
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: add /etc/depmod.d/dist.conf
* Fri Jan 25 2019 Xiaoqi Guo<guoxiaoqi2@huawei.com> - 25-2
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:add patches, include
bugfix-kmod-20-8-depmod-Don-t-unlinkat-orig-depfile-and-add-fsync.patch
* Thu Jan 24 2019 openEuler Buildteam <buildteam@openeuler.org> - 25-1
- Package init

View File

@ -1,6 +1,6 @@
Name: kmod Name: kmod
Version: 30 Version: 30
Release: 1 Release: 2
Summary: Kernel module management Summary: Kernel module management
# GPLv2+ is used by programs, LGPLv2+ is used for libraries. # GPLv2+ is used by programs, LGPLv2+ is used for libraries.
License: GPLv2+ and LGPLv2+ License: GPLv2+ and LGPLv2+
@ -13,6 +13,8 @@ BuildRequires: gcc chrpath zlib-devel xz-devel libxslt openssl-devel
Provides: module-init-tools = 4.0-1 Provides: module-init-tools = 4.0-1
Provides: /sbin/modprobe Provides: /sbin/modprobe
Patch: 0001-Module-replace-the-module-with-new-module.patch
Patch: 0002-Module-suspend-the-module-by-rmmod-r-option.patch
%description %description
The kmod package provides several commands to manage the kernel modules, The kmod package provides several commands to manage the kernel modules,
@ -115,89 +117,3 @@ install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/depmod.d/dist.conf
%doc TODO NEWS README.md %doc TODO NEWS README.md
%changelog %changelog
* Tue Jul 26 2022 Qingqing Li <liqingqing3@huawei.com> - 30-1
- upgrade to kmod-30
* Wed Jun 29 2022 luhuaxin <luhuaxin1@huawei.com> - 29-5
- support to display sm3 sig_hashalgo
* Thu Feb 24 2022 Yang Yanchao <yangyanchao6@huawei.com> - 29-4
- add package python3-kmod.
* Fri Jan 7 2022 zhouwenpei <zhouwenpei1@huawei.com> - 29-3
- kmod-devel: add requires on kmod-libs
* Thu Dec 9 2021 Jiangfeng Xiao <xiaojiangfeng@huawei.com> - 29-2
- kmod: revert "depmod: Do not unlinkat orig depfile and add fync"
* 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
Module: suspend the module by rmmod r option
* Wed Nov 24 2021 Yang Yanchao <yangyanchao6@huawei.com> - 27-7
- Precisely filters ko files in "/lib/modules/$kernel/extra"
to avoid creating unnecessary symbols.
* Tue Nov 9 2021 Yang Yanchao <yangyanchao6@huawei.com> - 27-6
- Sync the weak-modules script from the 20.03-LTS-SP1
- use -V to sort kernel version in weak-modules
* Fri Jun 18 2021 hushiyuan <hushiyuan@huawei.com> - 27-5
- libkmod-module: check "new_from_name" return value in get_builtin
- libkmod:fix double free for modinfo in modules.buildin.modinfo
- libkmod:fix an overflow with wrong modules.builtin.modinfo
- libkmod-config:fix a memory leak when kmod_list_append failes
- Fix "modinfo -F always shows name for build-ins"
* Thu Jan 14 2021 xinghe <xinghe1@huawei.com> - 27-4
- fix memory leak in kmodinfo and build warning
* Fri Sep 04 2020 xinghe <xinghe1@huawei.com> - 27-3
- backport patch to deal with lspci -v error report
* Fri Aug 21 2020 Wang Shuo<wangshuo_1994@foxmail.com> - 27-2
- remove unnecessary message
* Fri Apr 17 2020 Wang Shuo<wangshuo47@huawei.com> - 27-1
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: update kmod to 27
* Wed Feb 26 2020 Wang Shuo<wangshuo47@huawei.com> - 25-6
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: move libs files to libs package
* Sat Apr 6 2019 luochunsheng<luochunsheng@huawei.com> - 25-5
- Type:enhancement
- ID:NA
- SUG:NA
* Fri Mar 22 2019 kangenbo<kangenbo@huawei.com> - 25-4
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: backport patches from communities
* Tue Mar 19 2019 hexiaowen<hexiaowen@huawei.com> - 25-3
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: add /etc/depmod.d/dist.conf
* Fri Jan 25 2019 Xiaoqi Guo<guoxiaoqi2@huawei.com> - 25-2
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:add patches, include
bugfix-kmod-20-8-depmod-Don-t-unlinkat-orig-depfile-and-add-fsync.patch
* Thu Jan 24 2019 openEuler Buildteam <buildteam@openeuler.org> - 25-1
- Package init