From 3dd17ef9e0207e48e44b04fc1283bb75328005a1 Mon Sep 17 00:00:00 2001 From: yangyun Date: Sat, 30 Mar 2024 15:36:38 +0800 Subject: [PATCH] fix loading of fuse modules (cherry picked from commit 92b3e9421b0a69d97c4bb7b4ab2bc4f27f1f688f) --- 0011-Fix-loading-of-FUSE-modules.patch | 52 ++++++++++++++++++++++++++ fuse3.spec | 6 ++- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 0011-Fix-loading-of-FUSE-modules.patch diff --git a/0011-Fix-loading-of-FUSE-modules.patch b/0011-Fix-loading-of-FUSE-modules.patch new file mode 100644 index 0000000..eaf09b8 --- /dev/null +++ b/0011-Fix-loading-of-FUSE-modules.patch @@ -0,0 +1,52 @@ +From f317ce6a15d7dff6fb5c91e98cf6fbb0a28c6225 Mon Sep 17 00:00:00 2001 +From: Goswin von Brederlow +Date: Fri, 13 Jan 2023 10:36:52 +0100 +Subject: [PATCH] Fix loading of FUSE modules + +dlsym returns the address of the module factory symbol, not the actual function (#722) +pointer. Change the type of `factory` to `fuse_module_factory_t*` to reflect +this and then dereference it when registering the module. + +This is a followup to d92bf83, which introduced a NULL pointer dereference +when dlsym returns NULL, and 8ec7fd9, which reverted it back to not +dereferencing the symbol at all. + +Fixes: #721 + +Co-authored-by: Goswin von Brederlow +--- + lib/fuse.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/lib/fuse.c b/lib/fuse.c +index 44e4857..92f4bf0 100755 +--- a/lib/fuse.c ++++ b/lib/fuse.c +@@ -252,7 +252,7 @@ static int fuse_load_so_module(const char *module) + int ret = -1; + char *tmp; + struct fusemod_so *so; +- fuse_module_factory_t factory; ++ fuse_module_factory_t *factory; + + tmp = malloc(strlen(module) + 64); + if (!tmp) { +@@ -274,13 +274,13 @@ static int fuse_load_so_module(const char *module) + } + + sprintf(tmp, "fuse_module_%s_factory", module); +- *(void**)(&factory) = dlsym(so->handle, tmp); ++ factory = (fuse_module_factory_t*)dlsym(so->handle, tmp); + if (factory == NULL) { + fuse_log(FUSE_LOG_ERR, "fuse: symbol <%s> not found in module: %s\n", + tmp, dlerror()); + goto out_dlclose; + } +- ret = fuse_register_module(module, factory, so); ++ ret = fuse_register_module(module, *factory, so); + if (ret) + goto out_dlclose; + +-- +2.33.0 + diff --git a/fuse3.spec b/fuse3.spec index b2e9d35..80e6c50 100644 --- a/fuse3.spec +++ b/fuse3.spec @@ -2,7 +2,7 @@ Name: fuse3 Version: %{fuse3ver} -Release: 13 +Release: 14 Summary: User space File System of fuse3 License: GPL+ and LGPLv2+ URL: http://fuse.sf.net @@ -19,6 +19,7 @@ Patch7: 0007-Fix-use-after-free-warning.patch Patch8: 0008-Disable-leak-suppression-773.patch Patch9: 0009-Fix-memory-leak-in-high-level-API-781.patch Patch10: 0010-Fix-file-leak-in-high-level-API.patch +Patch11: 0011-Fix-loading-of-FUSE-modules.patch BuildRequires: libselinux-devel, pkgconfig, systemd-udev, meson, fdupes BuildRequires: autoconf, automake, libtool, gettext-devel, ninja-build @@ -109,6 +110,9 @@ install -p -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir} %{_mandir}/man8/* %changelog +* Sat Mar 30 2024 yangyun -3.9.2-14 +- fix loading of FUSE modules + * Sat Mar 30 2024 yangyun -3.9.2-13 - fix file leak in high level api -- Gitee