Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
abb2c26aaa
!97 libkmod: clear file->memory if map fails
From: @jamesblunt 
Reviewed-by: @liqingqing_1229 
Signed-off-by: @liqingqing_1229
2024-05-10 03:04:35 +00:00
zhangyaqi
fa9d30ce9b clear file memory if map fails 2024-05-10 10:17:51 +08:00
openeuler-ci-bot
4c6abf99d1
!95 [sync] PR-94: Reinitialize libtool to remove Rpath
From: @openeuler-sync-bot 
Reviewed-by: @liqingqing_1229 
Signed-off-by: @liqingqing_1229
2024-05-07 12:10:45 +00:00
guoqinglan
86d4e00188 Reinitialize libtool to remove Rpath
(cherry picked from commit a2d2298430e44983b9185fa27d8d615d3da65e6a)
2024-05-07 20:00:22 +08:00
openeuler-ci-bot
0ca540a207
!72 kmod: fit the old patches
From: @mistyriver 
Reviewed-by: @hjx_gitff, @yang_yanchao 
Signed-off-by: @yang_yanchao
2022-09-02 09:56:57 +00:00
fu.lin
a986201570 kmod: fix the patches
Signed-off-by: fu.lin <fulin10@huawei.com>
2022-09-02 14:16:02 +08:00
openeuler-ci-bot
20aa184fc6
!70 upgrade to kmod-30
From: @liqingqing_1229 
Reviewed-by: @wangbin224 
Signed-off-by: @wangbin224
2022-07-26 06:45:26 +00:00
liqingqing_1229
c72a878b92 upgrade to kmod-30 2022-07-26 14:34:11 +08:00
openeuler-ci-bot
504395adca
!67 Support to display sm3 sig_hashalgo
From: @HuaxinLuGitee 
Reviewed-by: @yang_yanchao 
Signed-off-by: @yang_yanchao
2022-06-29 08:14:28 +00:00
luhuaxin
95c8bcc97d Support to display sm3 sig_hashalgo 2022-06-29 15:47:59 +08:00
9 changed files with 158 additions and 172 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>
Date: Wed, 16 Sep 2020 01:21:50 +0000
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(-)
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
+++ 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;
if (flags & KMOD_INSERT_FORCE_MODVERSION)
kernel_flags |= MODULE_INIT_IGNORE_MODVERSIONS;
@ -28,10 +28,10 @@ index 714ee21..a243672 100644
goto init_finished;
}
diff --git a/libkmod/libkmod.h b/libkmod/libkmod.h
index 3cab2e5..241431e 100644
index 7251aa7..a56e5b4 100644
--- a/libkmod/libkmod.h
+++ b/libkmod/libkmod.h
@@ -148,6 +148,9 @@ enum kmod_remove {
@@ -153,6 +153,9 @@ enum kmod_remove {
enum kmod_insert {
KMOD_INSERT_FORCE_VERMAGIC = 0x1,
KMOD_INSERT_FORCE_MODVERSION = 0x2,
@ -41,7 +41,7 @@ index 3cab2e5..241431e 100644
};
/* 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_FAIL_ON_LOADED = 0x00020,
@ -104,5 +104,5 @@ index c422971..f0be196 100644
puts(PACKAGE " version " VERSION);
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>
Date: Fri, 25 Sep 2020 03:00:25 -0400
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(-)
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
+++ 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;
/* Filter out other flags and force ONONBLOCK */
@ -26,13 +26,13 @@ index a243672..70b633f 100644
err = delete_module(mod->name, flags);
diff --git a/libkmod/libkmod.h b/libkmod/libkmod.h
index 241431e..bcdefc4 100644
index a56e5b4..78d11b3 100644
--- a/libkmod/libkmod.h
+++ b/libkmod/libkmod.h
@@ -142,6 +142,9 @@ struct kmod_module *kmod_module_get_module(const struct kmod_list *entry);
enum kmod_remove {
KMOD_REMOVE_FORCE = O_TRUNC,
@@ -147,6 +147,9 @@ enum kmod_remove {
KMOD_REMOVE_NOWAIT = O_NONBLOCK, /* always set */
/* libkmod-only defines, not passed to kernel */
KMOD_REMOVE_NOLOG = 1,
+
+ /* custom flag */
+ KMOD_REMOVE_REPLACE = 0x1000,
@ -87,5 +87,5 @@ index 3942e7b..1278234 100644
use_syslog = 1;
break;
--
2.31.1
2.35.1

View File

@ -0,0 +1,40 @@
From 90b271fbd2b9708a8fa79b7e98d90c7919e7ed73 Mon Sep 17 00:00:00 2001
From: Emil Velikov <emil.l.velikov@gmail.com>
Date: Mon, 12 Feb 2024 17:23:05 +0000
Subject: libkmod: clear file->memory if map fails
On mmap failure file->memory is set to -1, which we'll happily pass down
to munmap later on.
More importantly, since we do a NULL check in kmod_file_load_contents()
we will exit the function without (re)attempting the load again.
Since we ignore the return code for the load function(s), one can end up
calling kmod_elf_get_memory() and feed that -1 into init_module.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
---
libkmod/libkmod-file.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libkmod/libkmod-file.c b/libkmod/libkmod-file.c
index b6a8cc9..1e1dd35 100644
--- a/libkmod/libkmod-file.c
+++ b/libkmod/libkmod-file.c
@@ -401,8 +401,10 @@ static int load_reg(struct kmod_file *file)
file->size = st.st_size;
file->memory = mmap(NULL, file->size, PROT_READ, MAP_PRIVATE,
file->fd, 0);
- if (file->memory == MAP_FAILED)
+ if (file->memory == MAP_FAILED) {
+ file->memory = NULL;
return -errno;
+ }
file->direct = true;
return 0;
}
--
2.27.0

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

Binary file not shown.

BIN
kmod-30.tar.xz Normal file

Binary file not shown.

93
kmod.changes Normal file
View File

@ -0,0 +1,93 @@
%changelog
* Tue May 07 2024 guoqinglan <guoqinglan@kylinsec.com.cn> - 30-3
- Reinitialize libtool to remove Rpath
* 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,5 +1,5 @@
Name: kmod
Version: 29
Version: 30
Release: 4
Summary: Kernel module management
# GPLv2+ is used by programs, LGPLv2+ is used for libraries.
@ -8,16 +8,15 @@ URL: http://git.kernel.org/?p=utils/kernel/kmod/kmod.git;a=summary
Source0: https://www.kernel.org/pub/linux/utils/kernel/kmod/%{name}-%{version}.tar.xz
Source1: weak-modules
Source2: depmod.conf.dist
Source3: kmod.changes
Patch1: 0001-libkmod-module-check-new_from_name-return-value-in-g.patch
Patch2: 0002-Module-replace-the-module-with-new-module.patch
Patch3: 0003-Module-suspend-the-module-by-rmmod-r-option.patch
Patch4: 0004-don-t-check-module-s-refcnt-when-rmmod-with-r.patch
BuildRequires: gcc chrpath zlib-devel xz-devel libxslt openssl-devel
BuildRequires: gcc chrpath zlib-devel xz-devel libxslt openssl-devel libtool gtk-doc
Provides: module-init-tools = 4.0-1
Provides: /sbin/modprobe
Patch: 0001-Module-replace-the-module-with-new-module.patch
Patch: 0002-Module-suspend-the-module-by-rmmod-r-option.patch
Patch: 0003-clear-file-memory-if-map-fails.patch
%description
The kmod package provides several commands to manage the kernel modules,
@ -60,6 +59,8 @@ developers to understand the kmod.
%autosetup -n %{name}-%{version} -p1
%build
# Reinitialize libtool to remove Rpath
autoreconf -vif
%configure --with-openssl --with-zlib --with-xz --enable-python
%make_build
@ -117,86 +118,6 @@ install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/depmod.d/dist.conf
%attr(0644,root,root) %{_mandir}/man5/*.5*
%attr(0644,root,root) %{_mandir}/man8/*.8*
%doc TODO NEWS README
%changelog
* 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
%doc TODO NEWS README.md
%include %{SOURCE3}