From 23b86dade9ffaaf7171a13bf8dfda66f10f2ebae Mon Sep 17 00:00:00 2001 From: "He, Xinzhe" Date: Thu, 20 Mar 2025 15:54:08 +0800 Subject: [PATCH] Libmount: Fix use option "owner" mount failed When use option "owner" to mount, libmount replaces the "owner" and "group" mount options with "nosuid,nodev". However, this can result in an "invaild argument" error because libmount removes the unwanted options first and then tries to address the location for the new options using the already removed options. To fix this, need to reverse the order of operations. Signed-off-by: He, Xinzhe --- ...nt-fix-use-option-owner-mount-failed.patch | 39 +++++++++++++++++++ util-linux.spec | 6 ++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 0002-mount-fix-use-option-owner-mount-failed.patch diff --git a/0002-mount-fix-use-option-owner-mount-failed.patch b/0002-mount-fix-use-option-owner-mount-failed.patch new file mode 100644 index 0000000..da10867 --- /dev/null +++ b/0002-mount-fix-use-option-owner-mount-failed.patch @@ -0,0 +1,39 @@ +From 4718f35bc5a779af058ff1e51aa6bf7096a0c076 Mon Sep 17 00:00:00 2001 +From: "He, Xinzhe" +Date: Thu, 20 Mar 2025 15:12:31 +0800 +Subject: [PATCH] mount-fix-use-option-owner-mount-failed + +Signed-off-by: He, Xinzhe +--- + libmount/src/context_mount.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c +index 50e4a62..4eaeb31 100644 +--- a/libmount/src/context_mount.c ++++ b/libmount/src/context_mount.c +@@ -202,10 +202,6 @@ static int evaluate_permissions(struct libmnt_context *cxt) + * + * The old deprecated way is to use mnt_optstr_get_flags(). + */ +- if (user_flags & (MNT_MS_OWNER | MNT_MS_GROUP)) +- rc = mnt_optlist_remove_flags(ol, +- MNT_MS_OWNER | MNT_MS_GROUP, cxt->map_userspace); +- + if (!rc && (user_flags & MNT_MS_OWNER)) + rc = mnt_optlist_insert_flags(ol, + MS_OWNERSECURE, cxt->map_linux, +@@ -226,6 +222,10 @@ static int evaluate_permissions(struct libmnt_context *cxt) + rc = mnt_optlist_insert_flags(ol, MS_SECURE, cxt->map_linux, + MNT_MS_USERS, cxt->map_userspace); + ++ if (user_flags & (MNT_MS_OWNER | MNT_MS_GROUP)) ++ rc = mnt_optlist_remove_flags(ol, ++ MNT_MS_OWNER | MNT_MS_GROUP, cxt->map_userspace); ++ + DBG(CXT, ul_debugobj(cxt, "perms: superuser [rc=%d]", rc)); + if (rc) + return rc; +-- +2.33.0 + diff --git a/util-linux.spec b/util-linux.spec index 7715609..31cfcf2 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -1,7 +1,7 @@ Summary: Collection of basic system utilities Name: util-linux Version: 2.39.1 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain URL: https://en.wikipedia.org/wiki/Util-linux @@ -95,6 +95,7 @@ Patch1: login-default-motd-file.patch ### Patch2: libmount-Fix-regression-when-mounting-with-atime.patch Patch3: 0001-fix-CVE-2024-28085.patch +Patch4: 0002-mount-fix-use-option-owner-mount-failed.patch %description @@ -877,6 +878,9 @@ fi %changelog +* Thu Mar 20 2025 He, Xinzhe - 2.39.1-3 +- fix use option "owner" mount failed + * Tue May 7 2024 dash - 2.39.1-2 - fix CVE-2024-28085 -- Gitee