From 90dd191b2b3eb2de040c1f3bccbb2a2969b56fe4 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Fri, 5 Jan 2024 18:52:56 +0100 Subject: [PATCH] added upstream path to fix libmount causing udisksd to crash [release 2.39-2mamba;Tue May 30 2023] --- ...libmount_dont_call_hooks_after_mount.patch | 82 +++++++++++++++++++ util-linux.spec | 7 +- 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 util-linux-2.39-upstream-libmount_dont_call_hooks_after_mount.patch diff --git a/util-linux-2.39-upstream-libmount_dont_call_hooks_after_mount.patch b/util-linux-2.39-upstream-libmount_dont_call_hooks_after_mount.patch new file mode 100644 index 0000000..3a4f7a9 --- /dev/null +++ b/util-linux-2.39-upstream-libmount_dont_call_hooks_after_mount.patch @@ -0,0 +1,82 @@ +From f94a7760ed7ce81389a6059f020238981627a70d Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Thu, 25 May 2023 11:48:24 +0200 +Subject: [PATCH] libmount: don't call hooks after mount. helper + +In case more filesystems are specified (or when libmount follows +/{etc,proc}/filesystems) then the library may try to use and +initialize the new API because for some filesystems, we need +exec(/sbin/mount.) and for another fsopen(). + +The hooks that use the API have to smart and detect that the mount +operation was done in external /sbin/mount. helper. And in this +case, the new API file descriptors must be ignored. + +The exception is propagation flags, mount(8) can set the flags after +exec(/sbin/mount.), for example, "mount -t ntfs --make-private". + +Fixes: https://github.com/util-linux/util-linux/issues/2267 +Signed-off-by: Karel Zak +--- + libmount/src/context_mount.c | 2 ++ + libmount/src/hook_mount.c | 13 +++++++++++++ + 2 files changed, 15 insertions(+) + +diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c +index cbb4f1fdfa..40f9ed0733 100644 +--- a/libmount/src/context_mount.c ++++ b/libmount/src/context_mount.c +@@ -508,6 +508,8 @@ static int do_mount(struct libmnt_context *cxt, const char *try_type) + assert(cxt->fs); + assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED)); + ++ mnt_context_reset_status(cxt); ++ + if (try_type) { + rc = mnt_context_prepare_helper(cxt, "mount", try_type); + if (rc) +diff --git a/libmount/src/hook_mount.c b/libmount/src/hook_mount.c +index 924c714448..91483afa68 100644 +--- a/libmount/src/hook_mount.c ++++ b/libmount/src/hook_mount.c +@@ -239,6 +239,10 @@ static int hook_create_mount(struct libmnt_context *cxt, + int rc = 0; + + assert(cxt); ++ ++ if (mnt_context_helper_executed(cxt)) ++ return 0; ++ + assert(cxt->fs); + + api = get_sysapi(cxt); +@@ -309,6 +313,9 @@ static int hook_reconfigure_mount(struct libmnt_context *cxt, + + assert(cxt); + ++ if (mnt_context_helper_executed(cxt)) ++ return 0; ++ + api = get_sysapi(cxt); + assert(api); + assert(api->fd_tree >= 0); +@@ -379,6 +386,9 @@ static int hook_set_vfsflags(struct libmnt_context *cxt, + uint64_t set = 0, clr = 0; + int rc = 0; + ++ if (mnt_context_helper_executed(cxt)) ++ return 0; ++ + DBG(HOOK, ul_debugobj(hs, "setting VFS flags")); + + ol = mnt_context_get_optlist(cxt); +@@ -471,6 +481,9 @@ static int hook_attach_target(struct libmnt_context *cxt, + const char *target; + int rc = 0; + ++ if (mnt_context_helper_executed(cxt)) ++ return 0; ++ + target = mnt_fs_get_target(cxt->fs); + if (!target) + return -EINVAL; diff --git a/util-linux.spec b/util-linux.spec index 2e2ae9a..9d7ce5a 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -8,7 +8,7 @@ Name: util-linux Version: 2.39 -Release: 1mamba +Release: 2mamba Epoch: 1 Summary: Miscellaneous utilities for Linux Group: System/Tools @@ -35,6 +35,7 @@ Patch1: %{name}-ng-2.15-reiserfs_fix_name.patch Patch2: util-linux-2.22-su_paths.patch Patch3: util-linux-2.34-blkid-pkgconfig-add-uuid.patch Patch4: util-linux-2.36.1-revert-add-nosymfollow.patch +Patch5: util-linux-2.39-upstream-libmount_dont_call_hooks_after_mount.patch License: GPL ## AUTOBUILDREQ-BEGIN BuildRequires: glibc-devel @@ -183,6 +184,7 @@ Python binding to libmount. #:<< _EOF %patch 3 -p1 #%patch4 -p1 -R +%patch5 -p1 -b .upstream-libmount_dont_call_hooks_after_mount #cp %{S:1} nologin.c @@ -413,6 +415,9 @@ exit 0 %{_libdir}/pkgconfig/fdisk.pc %changelog +* Tue May 30 2023 Silvan Calarco 2.39-2mamba +- added upstream path to fix libmount causing udisksd to crash + * Sat May 20 2023 Automatic Build System 2.39-1mamba - automatic version update by autodist