2.39-0.4: fix libmount

This commit is contained in:
Karel Zak 2023-04-05 21:59:20 +02:00
parent 5fa93ec5e0
commit 09904cbd56
2 changed files with 120 additions and 1 deletions

View File

@ -0,0 +1,110 @@
From c7ffe0cf6b7bdf62db70bd7700d6ed40d9106ba9 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Wed, 5 Apr 2023 21:44:55 +0200
Subject: [PATCH] libmount: fix superblock rw/ro reconfiguration
The classic mount(2) defaults to 'rw', but the new API does not reset
superblock to 'rw' if the flag is not explicitly used for
FSCONFIG_CMD_RECONFIGURE.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2180593
Signed-off-by: Karel Zak <kzak@redhat.com>
---
libmount/src/hook_mount.c | 47 +++++++++++++++++++++++++++------------
1 file changed, 33 insertions(+), 14 deletions(-)
diff --git a/libmount/src/hook_mount.c b/libmount/src/hook_mount.c
index 071dad783..117150dec 100644
--- a/libmount/src/hook_mount.c
+++ b/libmount/src/hook_mount.c
@@ -111,14 +111,33 @@ static int hookset_deinit(struct libmnt_context *cxt, const struct libmnt_hookse
return 0;
}
+static inline int fsconfig_set_value(
+ struct libmnt_context *cxt,
+ const struct libmnt_hookset *hs,
+ int fd,
+ const char *name, const char *value)
+{
+ int rc;
+
+ DBG(HOOK, ul_debugobj(hs, " fsconfig(name=%s,value=%s)", name,
+ value ? : ""));
+ if (value)
+ rc = fsconfig(fd, FSCONFIG_SET_STRING, name, value, 0);
+ else
+ rc = fsconfig(fd, FSCONFIG_SET_FLAG, name, NULL, 0);
+
+ set_syscall_status(cxt, "fsconfig", rc == 0);
+ return rc;
+}
static int configure_superblock(struct libmnt_context *cxt,
- const struct libmnt_hookset *hs, int fd)
+ const struct libmnt_hookset *hs,
+ int fd, int force_rwro)
{
struct libmnt_optlist *ol;
struct libmnt_iter itr;
struct libmnt_opt *opt;
- int rc;
+ int rc = 0, has_rwro = 0;
DBG(HOOK, ul_debugobj(hs, " config FS"));
@@ -136,22 +155,21 @@ static int configure_superblock(struct libmnt_context *cxt,
if (ent && mnt_opt_get_map(opt) == cxt->map_linux &&
ent->id == MS_RDONLY) {
value = NULL;
+ has_rwro = 1;
} else if (!name || mnt_opt_get_map(opt) || mnt_opt_is_external(opt))
continue;
- DBG(HOOK, ul_debugobj(hs, " fsconfig(name=%s,value=%s)", name, value));
- if (value)
- rc = fsconfig(fd, FSCONFIG_SET_STRING, name, value, 0);
- else
- rc = fsconfig(fd, FSCONFIG_SET_FLAG, name, NULL, 0);
-
- set_syscall_status(cxt, "fsconfig", rc == 0);
+ rc = fsconfig_set_value(cxt, hs, fd, name, value);
if (rc != 0)
- return -errno;
+ goto done;
}
- DBG(HOOK, ul_debugobj(hs, " config done [rc=0]"));
- return 0;
+ if (force_rwro && !has_rwro)
+ rc = fsconfig_set_value(cxt, hs, fd, "rw", NULL);
+
+done:
+ DBG(HOOK, ul_debugobj(hs, " config done [rc=%d]", rc));
+ return rc != 0 && errno ? -errno : rc;
}
static int open_fs_configuration_context(struct libmnt_context *cxt,
@@ -244,7 +262,7 @@ static int hook_create_mount(struct libmnt_context *cxt,
set_syscall_status(cxt, "fsconfig", rc == 0);
if (!rc)
- rc = configure_superblock(cxt, hs, api->fd_fs);
+ rc = configure_superblock(cxt, hs, api->fd_fs, 0);
if (!rc) {
DBG(HOOK, ul_debugobj(hs, "create FS"));
rc = fsconfig(api->fd_fs, FSCONFIG_CMD_CREATE, NULL, NULL, 0);
@@ -301,8 +319,9 @@ static int hook_reconfigure_mount(struct libmnt_context *cxt,
return -errno;
}
- rc = configure_superblock(cxt, hs, api->fd_fs);
+ rc = configure_superblock(cxt, hs, api->fd_fs, 1);
if (!rc) {
+ DBG(HOOK, ul_debugobj(hs, "re-configurate FS"));
rc = fsconfig(api->fd_fs, FSCONFIG_CMD_RECONFIGURE, NULL, NULL, 0);
set_syscall_status(cxt, "fsconfig", rc == 0);
}
--
2.39.2

View File

@ -2,7 +2,7 @@
Summary: Collection of basic system utilities Summary: Collection of basic system utilities
Name: util-linux Name: util-linux
Version: 2.39 Version: 2.39
Release: 0.3%{?dist} Release: 0.4%{?dist}
License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain
URL: https://en.wikipedia.org/wiki/Util-linux URL: https://en.wikipedia.org/wiki/Util-linux
@ -94,6 +94,9 @@ Patch0: login-lastlog-create.patch
# https://github.com/coreos/console-login-helper-messages/issues/60 # https://github.com/coreos/console-login-helper-messages/issues/60
Patch1: login-default-motd-file.patch Patch1: login-default-motd-file.patch
# upstream (#2180593)
Patch2: libmount-fix-superblock-rw-ro-reconfiguration.patch
%description %description
The util-linux package contains a large variety of low-level system The util-linux package contains a large variety of low-level system
utilities that are necessary for a Linux system to function. Among utilities that are necessary for a Linux system to function. Among
@ -918,6 +921,12 @@ fi
%{_libdir}/python*/site-packages/libmount/ %{_libdir}/python*/site-packages/libmount/
%changelog %changelog
* Wed Apr 5 2023 Karel Zak <kzak@redhat.com> - 2.39-0.4
- fix #2180593 (superblock reconfiguration libmount issue)
* Tue Apr 4 2023 Karel Zak <kzak@redhat.com> - 2.39-0.3
- fix spec file
* Tue Apr 4 2023 Karel Zak <kzak@redhat.com> - 2.39-0.2 * Tue Apr 4 2023 Karel Zak <kzak@redhat.com> - 2.39-0.2
- upgrade to v2.39-rc2 - upgrade to v2.39-rc2