aboutsummaryrefslogtreecommitdiffstats
path: root/libmount/src
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2025-02-24 14:04:53 +0100
committerKarel Zak <kzak@redhat.com>2025-02-24 14:04:53 +0100
commit4aa39b894dbb80eab45af53a011224a43b687b94 (patch)
treea1286730e609d8030631db3dc1da770d05a05112 /libmount/src
parent3564de4d10aa0f4b51ab8b7d8b5fa268fa770720 (diff)
downloadutil-linux-4aa39b894dbb80eab45af53a011224a43b687b94.tar.gz
Libmount: Fix removal of "owner" option when executed as root
When executed as root, libmount replaces the "owner" and "group" mount options with "nosuid, nodev, ..." However, this can result in an "invalid 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, we need to reverse the order of operations. Reported-by: hxinzhe <hxinzhe1024@163.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src')
-rw-r--r--libmount/src/context_mount.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c
index f2fa630f7a..fbb2007081 100644
--- a/libmount/src/context_mount.c
+++ b/libmount/src/context_mount.c
@@ -203,10 +203,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,
@@ -227,6 +223,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;