sync community patches
(cherry picked from commit 8682196b268acf24f3633b852b71ea24f0c087d6)
This commit is contained in:
parent
d4b8dfdb3e
commit
18a0dbcba9
85
backport-libmount-Fix-atime-remount-for-new-API.patch
Normal file
85
backport-libmount-Fix-atime-remount-for-new-API.patch
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
From 46eed8e1649cb8446d4c051ad1f1821cf3adca1a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Karel Zak <kzak@redhat.com>
|
||||||
|
Date: Tue, 14 May 2024 11:58:20 +0200
|
||||||
|
Subject: [PATCH] libmount: Fix atime remount for new API
|
||||||
|
|
||||||
|
All atime settings are mutually exclusive, and the attr_set mask for
|
||||||
|
the mount_setattr() syscall cannot contain multiple MOUNT_ATTR_ atime
|
||||||
|
related options.
|
||||||
|
|
||||||
|
Unfortunately, during a remount, the list of options is composed of
|
||||||
|
both old and new options. In this case, libmount sets more atime
|
||||||
|
options to the mask. The correct behavior is to use the last atime
|
||||||
|
related option from the list.
|
||||||
|
|
||||||
|
Fixes: https://github.com/util-linux/util-linux/issues/3032
|
||||||
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
||||||
|
---
|
||||||
|
libmount/src/optlist.c | 33 +++++++++++++++++++++------------
|
||||||
|
1 file changed, 21 insertions(+), 12 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libmount/src/optlist.c b/libmount/src/optlist.c
|
||||||
|
index 476acfd65..e32489627 100644
|
||||||
|
--- a/libmount/src/optlist.c
|
||||||
|
+++ b/libmount/src/optlist.c
|
||||||
|
@@ -837,6 +837,7 @@ int mnt_optlist_get_attrs(struct libmnt_optlist *ls, uint64_t *set, uint64_t *cl
|
||||||
|
struct libmnt_iter itr;
|
||||||
|
struct libmnt_opt *opt;
|
||||||
|
uint64_t remount_reset = 0;
|
||||||
|
+ uint64_t atime_set = 0;
|
||||||
|
|
||||||
|
if (!ls || !ls->linux_map || !set || !clr)
|
||||||
|
return -EINVAL;
|
||||||
|
@@ -879,29 +880,37 @@ int mnt_optlist_get_attrs(struct libmnt_optlist *ls, uint64_t *set, uint64_t *cl
|
||||||
|
remount_reset &= ~x;
|
||||||
|
|
||||||
|
if (opt->ent->mask & MNT_INVERT) {
|
||||||
|
- DBG(OPTLIST, ul_debugobj(ls, " clr: %s", opt->ent->name));
|
||||||
|
- /*
|
||||||
|
- * All atime settings are mutually exclusive so *clr must
|
||||||
|
- * have MOUNT_ATTR__ATIME set.
|
||||||
|
- *
|
||||||
|
- * See the function fs/namespace.c:build_mount_kattr()
|
||||||
|
- * in the linux kernel source.
|
||||||
|
- */
|
||||||
|
+ DBG(OPTLIST, ul_debugobj(ls, " clr: %s 0x%08" PRIx64,
|
||||||
|
+ opt->ent->name, x));
|
||||||
|
+
|
||||||
|
if (x == MOUNT_ATTR_RELATIME || x == MOUNT_ATTR_NOATIME ||
|
||||||
|
x == MOUNT_ATTR_STRICTATIME)
|
||||||
|
*clr |= MOUNT_ATTR__ATIME;
|
||||||
|
else
|
||||||
|
*clr |= x;
|
||||||
|
} else {
|
||||||
|
- DBG(OPTLIST, ul_debugobj(ls, " set: %s", opt->ent->name));
|
||||||
|
- *set |= x;
|
||||||
|
-
|
||||||
|
if (x == MOUNT_ATTR_RELATIME || x == MOUNT_ATTR_NOATIME ||
|
||||||
|
- x == MOUNT_ATTR_STRICTATIME)
|
||||||
|
+ x == MOUNT_ATTR_STRICTATIME) {
|
||||||
|
+ /* All atime settings are mutually exclusive,
|
||||||
|
+ * the last option wins and MOUNT_ATTR__ATIME
|
||||||
|
+ * is required in clr mask.
|
||||||
|
+ */
|
||||||
|
+ DBG(OPTLIST, ul_debugobj(ls, " atime: %s 0x%08" PRIx64,
|
||||||
|
+ opt->ent->name, x));
|
||||||
|
*clr |= MOUNT_ATTR__ATIME;
|
||||||
|
+ atime_set = x;
|
||||||
|
+ } else {
|
||||||
|
+ DBG(OPTLIST, ul_debugobj(ls, " set: %s 0x%08" PRIx64,
|
||||||
|
+ opt->ent->name, x));
|
||||||
|
+ *set |= x;
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if (atime_set) {
|
||||||
|
+ DBG(OPTLIST, ul_debugobj(ls, " set atime 0x%08" PRIx64, atime_set));
|
||||||
|
+ *set |= atime_set;
|
||||||
|
+ }
|
||||||
|
if (remount_reset)
|
||||||
|
*clr |= remount_reset;
|
||||||
|
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
133
backport-libmount-Fix-regression-when-mounting-with-atime.patch
Normal file
133
backport-libmount-Fix-regression-when-mounting-with-atime.patch
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
From 2b99ee2526ae61be761b0e31c50e106dbec5e9e4 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Filipe Manana <fdmanana@kernel.org>
|
||||||
|
Date: Thu, 17 Aug 2023 10:20:13 +0100
|
||||||
|
Subject: [PATCH] libmount: Fix regression when mounting with atime
|
||||||
|
|
||||||
|
A regression was introduced in v2.39 that causes mounting with the atime
|
||||||
|
option to fail:
|
||||||
|
|
||||||
|
$ mkfs.ext4 -F /dev/sdi
|
||||||
|
$ mount -o atime /dev/sdi /mnt/sdi
|
||||||
|
mount: /mnt/sdi: not mount point or bad option.
|
||||||
|
dmesg(1) may have more information after failed mount system call.
|
||||||
|
|
||||||
|
The failure comes from the mount_setattr(2) call returning -EINVAL. This
|
||||||
|
is because we pass an invalid value for the attr_clr argument. From a
|
||||||
|
strace capture we have:
|
||||||
|
|
||||||
|
mount_setattr(4, "", AT_EMPTY_PATH, {attr_set=0, attr_clr=MOUNT_ATTR_NOATIME, propagation=0 /* MS_??? */, userns_fd=0}, 32) = -1 EINVAL (Invalid argument)
|
||||||
|
|
||||||
|
We can't pass MOUNT_ATTR_NOATIME to mount_setattr(2) through the attr_clr
|
||||||
|
argument because all atime options are exclusive, so in order to set atime
|
||||||
|
one has to pass MOUNT_ATTR__ATIME to attr_clr and leave attr_set as
|
||||||
|
MOUNT_ATTR_RELATIME (which is defined as a value of 0).
|
||||||
|
|
||||||
|
This can be read from the man page for mount_setattr(2) and also from the
|
||||||
|
kernel source:
|
||||||
|
|
||||||
|
$ cat fs/namespace.c
|
||||||
|
static int build_mount_kattr(const struct mount_attr *attr, size_t usize,
|
||||||
|
struct mount_kattr *kattr, unsigned int flags)
|
||||||
|
{
|
||||||
|
(...)
|
||||||
|
/*
|
||||||
|
* Since the MOUNT_ATTR_<atime> values are an enum, not a bitmap,
|
||||||
|
* users wanting to transition to a different atime setting cannot
|
||||||
|
* simply specify the atime setting in @attr_set, but must also
|
||||||
|
* specify MOUNT_ATTR__ATIME in the @attr_clr field.
|
||||||
|
* So ensure that MOUNT_ATTR__ATIME can't be partially set in
|
||||||
|
* @attr_clr and that @attr_set can't have any atime bits set if
|
||||||
|
* MOUNT_ATTR__ATIME isn't set in @attr_clr.
|
||||||
|
*/
|
||||||
|
if (attr->attr_clr & MOUNT_ATTR__ATIME) {
|
||||||
|
if ((attr->attr_clr & MOUNT_ATTR__ATIME) != MOUNT_ATTR__ATIME)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Clear all previous time settings as they are mutually
|
||||||
|
* exclusive.
|
||||||
|
*/
|
||||||
|
kattr->attr_clr |= MNT_RELATIME | MNT_NOATIME;
|
||||||
|
switch (attr->attr_set & MOUNT_ATTR__ATIME) {
|
||||||
|
case MOUNT_ATTR_RELATIME:
|
||||||
|
kattr->attr_set |= MNT_RELATIME;
|
||||||
|
break;
|
||||||
|
case MOUNT_ATTR_NOATIME:
|
||||||
|
kattr->attr_set |= MNT_NOATIME;
|
||||||
|
break;
|
||||||
|
case MOUNT_ATTR_STRICTATIME:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
(...)
|
||||||
|
|
||||||
|
So fix this by setting attr_clr MOUNT_ATTR__ATIME if we want to clear any
|
||||||
|
atime related option.
|
||||||
|
|
||||||
|
Signed-off-by: Filipe Manana <fdmanana@kernel.org>
|
||||||
|
---
|
||||||
|
libmount/src/optlist.c | 13 ++++++++++++-
|
||||||
|
tests/expected/libmount/context-mount-flags | 3 +++
|
||||||
|
tests/ts/libmount/context | 9 ++++++++-
|
||||||
|
3 files changed, 23 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libmount/src/optlist.c b/libmount/src/optlist.c
|
||||||
|
index e93810b47..d0afc94f7 100644
|
||||||
|
--- a/libmount/src/optlist.c
|
||||||
|
+++ b/libmount/src/optlist.c
|
||||||
|
@@ -875,7 +875,18 @@ int mnt_optlist_get_attrs(struct libmnt_optlist *ls, uint64_t *set, uint64_t *cl
|
||||||
|
|
||||||
|
if (opt->ent->mask & MNT_INVERT) {
|
||||||
|
DBG(OPTLIST, ul_debugobj(ls, " clr: %s", opt->ent->name));
|
||||||
|
- *clr |= x;
|
||||||
|
+ /*
|
||||||
|
+ * All atime settings are mutually exclusive so *clr must
|
||||||
|
+ * have MOUNT_ATTR__ATIME set.
|
||||||
|
+ *
|
||||||
|
+ * See the function fs/namespace.c:build_mount_kattr()
|
||||||
|
+ * in the linux kernel source.
|
||||||
|
+ */
|
||||||
|
+ if (x == MOUNT_ATTR_RELATIME || x == MOUNT_ATTR_NOATIME ||
|
||||||
|
+ x == MOUNT_ATTR_STRICTATIME)
|
||||||
|
+ *clr |= MOUNT_ATTR__ATIME;
|
||||||
|
+ else
|
||||||
|
+ *clr |= x;
|
||||||
|
} else {
|
||||||
|
DBG(OPTLIST, ul_debugobj(ls, " set: %s", opt->ent->name));
|
||||||
|
*set |= x;
|
||||||
|
diff --git a/tests/expected/libmount/context-mount-flags b/tests/expected/libmount/context-mount-flags
|
||||||
|
index 960641863..eb71323dd 100644
|
||||||
|
--- a/tests/expected/libmount/context-mount-flags
|
||||||
|
+++ b/tests/expected/libmount/context-mount-flags
|
||||||
|
@@ -3,3 +3,6 @@ ro,nosuid,noexec
|
||||||
|
successfully mounted
|
||||||
|
rw,nosuid,noexec
|
||||||
|
successfully umounted
|
||||||
|
+successfully mounted
|
||||||
|
+rw,relatime
|
||||||
|
+successfully umounted
|
||||||
|
diff --git a/tests/ts/libmount/context b/tests/ts/libmount/context
|
||||||
|
index f5b47185e..a5d2e81a3 100755
|
||||||
|
--- a/tests/ts/libmount/context
|
||||||
|
+++ b/tests/ts/libmount/context
|
||||||
|
@@ -116,8 +116,15 @@ $TS_CMD_FINDMNT --kernel --mountpoint $MOUNTPOINT -o VFS-OPTIONS -n >> $TS_OUTPU
|
||||||
|
|
||||||
|
ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
|
||||||
|
is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
|
||||||
|
-ts_finalize_subtest
|
||||||
|
|
||||||
|
+# Test that the atime option works after the migration to use the new kernel mount APIs.
|
||||||
|
+ts_run $TESTPROG --mount -o atime $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
|
||||||
|
+$TS_CMD_FINDMNT --kernel --mountpoint $MOUNTPOINT -o VFS-OPTIONS -n >> $TS_OUTPUT 2>> $TS_ERRLOG
|
||||||
|
+is_mounted $DEVICE || echo "$DEVICE not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
|
||||||
|
+ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG
|
||||||
|
+is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG
|
||||||
|
+
|
||||||
|
+ts_finalize_subtest
|
||||||
|
|
||||||
|
ts_init_subtest "mount-loopdev"
|
||||||
|
mkdir -p $MOUNTPOINT &> /dev/null
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
30
backport-libmount-fix-possible-memory-leak.patch
Normal file
30
backport-libmount-fix-possible-memory-leak.patch
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
From 35ad7bf065db668d6604261066f049982563dabd Mon Sep 17 00:00:00 2001
|
||||||
|
From: Karel Zak <kzak@redhat.com>
|
||||||
|
Date: Thu, 2 May 2024 10:15:29 +0200
|
||||||
|
Subject: [PATCH] libmount: fix possible memory leak
|
||||||
|
|
||||||
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
||||||
|
---
|
||||||
|
libmount/src/context_mount.c | 5 +++--
|
||||||
|
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c
|
||||||
|
index 50e4a62..d0da770 100644
|
||||||
|
--- a/libmount/src/context_mount.c
|
||||||
|
+++ b/libmount/src/context_mount.c
|
||||||
|
@@ -541,9 +541,10 @@ static int do_mount(struct libmnt_context *cxt, const char *try_type)
|
||||||
|
if (!rc)
|
||||||
|
rc = mnt_context_call_hooks(cxt, MNT_STAGE_MOUNT);
|
||||||
|
|
||||||
|
- if (org_type && rc != 0)
|
||||||
|
+ if (org_type && rc != 0) {
|
||||||
|
__mnt_fs_set_fstype_ptr(cxt->fs, org_type);
|
||||||
|
- org_type = NULL;
|
||||||
|
+ org_type = NULL;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
if (rc == 0 && try_type && cxt->update) {
|
||||||
|
struct libmnt_fs *fs = mnt_update_get_fs(cxt->update);
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
55
backport-libmount-ifdef-statx-call.patch
Normal file
55
backport-libmount-ifdef-statx-call.patch
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
From ce266c9e168d4f88ae04fea3f9984deb9d9a5dfd Mon Sep 17 00:00:00 2001
|
||||||
|
From: Karel Zak <kzak@redhat.com>
|
||||||
|
Date: Thu, 3 Aug 2023 12:39:19 +0200
|
||||||
|
Subject: [PATCH] libmount: ifdef statx() call
|
||||||
|
|
||||||
|
In this case the statx() is use to get mount ID. It's optional and not
|
||||||
|
required. Let's #ifdef the statx() call and also check for stx_mnt_id
|
||||||
|
struct member.
|
||||||
|
|
||||||
|
Fixes: https://github.com/util-linux/util-linux/issues/2415
|
||||||
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
||||||
|
---
|
||||||
|
configure.ac | 5 ++++-
|
||||||
|
libmount/src/hook_mount.c | 2 ++
|
||||||
|
2 files changed, 6 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/configure.ac b/configure.ac
|
||||||
|
index 13eb6c1e6..b075f0265 100644
|
||||||
|
--- a/configure.ac
|
||||||
|
+++ b/configure.ac
|
||||||
|
@@ -514,7 +514,10 @@ AC_CHECK_MEMBERS([struct termios.c_line],,,
|
||||||
|
[[#include <termios.h>]])
|
||||||
|
|
||||||
|
AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec],,,
|
||||||
|
- [#include <sys/stat.h>])
|
||||||
|
+ [[#include <sys/stat.h>]])
|
||||||
|
+
|
||||||
|
+AC_CHECK_MEMBERS([struct statx.stx_mnt_id],,,
|
||||||
|
+ [[#include <linux/stat.h>]])
|
||||||
|
|
||||||
|
AC_CHECK_DECLS([_NL_TIME_WEEK_1STDAY],[],[],[[#include <langinfo.h>]])
|
||||||
|
|
||||||
|
diff --git a/libmount/src/hook_mount.c b/libmount/src/hook_mount.c
|
||||||
|
index d69a018ec..056338c49 100644
|
||||||
|
--- a/libmount/src/hook_mount.c
|
||||||
|
+++ b/libmount/src/hook_mount.c
|
||||||
|
@@ -294,6 +294,7 @@ static int hook_create_mount(struct libmnt_context *cxt,
|
||||||
|
/* cleanup after fail (libmount may only try the FS type) */
|
||||||
|
close_sysapi_fds(api);
|
||||||
|
|
||||||
|
+#if defined(HAVE_STRUCT_STATX) && defined(HAVE_STRUCT_STATX_STX_MNT_ID)
|
||||||
|
if (!rc && cxt->fs) {
|
||||||
|
struct statx st;
|
||||||
|
|
||||||
|
@@ -306,6 +307,7 @@ static int hook_create_mount(struct libmnt_context *cxt,
|
||||||
|
fs->id = cxt->fs->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
done:
|
||||||
|
DBG(HOOK, ul_debugobj(hs, "create FS done [rc=%d, id=%d]", rc, cxt->fs ? cxt->fs->id : -1));
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
76
backport-libmount-improve-mnt_table_next_child_fs.patch
Normal file
76
backport-libmount-improve-mnt_table_next_child_fs.patch
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
From f64ea9979a5eaddaed98bde17832f855f2f0daee Mon Sep 17 00:00:00 2001
|
||||||
|
From: Karel Zak <kzak@redhat.com>
|
||||||
|
Date: Thu, 2 Nov 2023 10:41:03 +0100
|
||||||
|
Subject: [PATCH] libmount: improve mnt_table_next_child_fs()
|
||||||
|
|
||||||
|
The function utilizes the struct libmnt_itr to iterate through the mountinfo file
|
||||||
|
but neglects the direction specified by the iterator. This a bug. The application
|
||||||
|
must manage the direction, as, for instance, umount(8) requires the children of
|
||||||
|
the mountpoint in reverse order.
|
||||||
|
|
||||||
|
Fixes: https://github.com/util-linux/util-linux/issues/2552
|
||||||
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
||||||
|
---
|
||||||
|
libmount/src/tab.c | 25 ++++++++++++++++++-------
|
||||||
|
1 file changed, 18 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libmount/src/tab.c b/libmount/src/tab.c
|
||||||
|
index 60bef8b2d..5c2d5c868 100644
|
||||||
|
--- a/libmount/src/tab.c
|
||||||
|
+++ b/libmount/src/tab.c
|
||||||
|
@@ -650,8 +650,8 @@ int mnt_table_get_root_fs(struct libmnt_table *tb, struct libmnt_fs **root)
|
||||||
|
* @parent: parental FS
|
||||||
|
* @chld: NULL or returns the next child filesystem
|
||||||
|
*
|
||||||
|
- * Note that filesystems are returned in the order of mounting (according to
|
||||||
|
- * IDs in /proc/self/mountinfo).
|
||||||
|
+ * Since version 2.40, the filesystems are returned in the order specified by
|
||||||
|
+ * @itr. In the old versions the derection is always MNT_ITER_FORWARD.
|
||||||
|
*
|
||||||
|
* Returns: 0 on success, negative number in case of error or 1 at the end of list.
|
||||||
|
*/
|
||||||
|
@@ -660,6 +660,7 @@ int mnt_table_next_child_fs(struct libmnt_table *tb, struct libmnt_iter *itr,
|
||||||
|
{
|
||||||
|
struct libmnt_fs *fs, *chfs = NULL;
|
||||||
|
int parent_id, lastchld_id = 0, chld_id = 0;
|
||||||
|
+ int direction = mnt_iter_get_direction(itr);
|
||||||
|
|
||||||
|
if (!tb || !itr || !parent || !is_mountinfo(tb))
|
||||||
|
return -EINVAL;
|
||||||
|
@@ -675,7 +676,7 @@ int mnt_table_next_child_fs(struct libmnt_table *tb, struct libmnt_iter *itr,
|
||||||
|
lastchld_id = mnt_fs_get_id(fs);
|
||||||
|
}
|
||||||
|
|
||||||
|
- mnt_reset_iter(itr, MNT_ITER_FORWARD);
|
||||||
|
+ mnt_reset_iter(itr, direction);
|
||||||
|
while (mnt_table_next_fs(tb, itr, &fs) == 0) {
|
||||||
|
int id;
|
||||||
|
|
||||||
|
@@ -689,10 +690,20 @@ int mnt_table_next_child_fs(struct libmnt_table *tb, struct libmnt_iter *itr,
|
||||||
|
if (id == parent_id)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
- if ((!lastchld_id || id > lastchld_id) &&
|
||||||
|
- (!chfs || id < chld_id)) {
|
||||||
|
- chfs = fs;
|
||||||
|
- chld_id = id;
|
||||||
|
+ if (direction == MNT_ITER_FORWARD) {
|
||||||
|
+ /* return in the order of mounting */
|
||||||
|
+ if ((!lastchld_id || id > lastchld_id) &&
|
||||||
|
+ (!chfs || id < chld_id)) {
|
||||||
|
+ chfs = fs;
|
||||||
|
+ chld_id = id;
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ /* return last child first */
|
||||||
|
+ if ((!lastchld_id || id < lastchld_id) &&
|
||||||
|
+ (!chfs || id > chld_id)) {
|
||||||
|
+ chfs = fs;
|
||||||
|
+ chld_id = id;
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
111
backport-libmount-make-sure-option-is-used-as-string.patch
Normal file
111
backport-libmount-make-sure-option-is-used-as-string.patch
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
From 0c5485348b155420ecd1bfcdabb1b869ca5ee3c2 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Karel Zak <kzak@redhat.com>
|
||||||
|
Date: Wed, 20 Mar 2024 16:08:16 +0100
|
||||||
|
Subject: [PATCH] libmount: make sure "option=" is used as string
|
||||||
|
|
||||||
|
mount(8) cares about case when option specified as "name=" (it means
|
||||||
|
without data). See for example 727c689908c5e68c92aa1dd65e0d3bdb6d91c1e5.
|
||||||
|
|
||||||
|
We need this also for new mount API and use FSCONFIG_SET_STRING rather
|
||||||
|
than FSCONFIG_SET_FLAG.
|
||||||
|
|
||||||
|
strace -e fsconfig ./mount -o usrjquota= /dev/sdc1 /mnt/test
|
||||||
|
|
||||||
|
Old:
|
||||||
|
fsconfig(3, FSCONFIG_SET_STRING, "source", "/dev/sdc1", 0) = 0
|
||||||
|
fsconfig(3, FSCONFIG_SET_FLAG, "usrjquota", NULL, 0) = -1 EINVAL (Invalid argument)
|
||||||
|
|
||||||
|
Fixed:
|
||||||
|
fsconfig(3, FSCONFIG_SET_STRING, "source", "/dev/sdc1", 0) = 0
|
||||||
|
fsconfig(3, FSCONFIG_SET_STRING, "usrjquota", "", 0) = 0
|
||||||
|
|
||||||
|
Fixes: https://github.com/util-linux/util-linux/issues/2837
|
||||||
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
||||||
|
---
|
||||||
|
libmount/src/hook_mount.c | 3 +++
|
||||||
|
libmount/src/mountP.h | 1 +
|
||||||
|
libmount/src/optlist.c | 14 +++++++++++++-
|
||||||
|
3 files changed, 17 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/libmount/src/hook_mount.c b/libmount/src/hook_mount.c
|
||||||
|
index 92438966c..f0cc38196 100644
|
||||||
|
--- a/libmount/src/hook_mount.c
|
||||||
|
+++ b/libmount/src/hook_mount.c
|
||||||
|
@@ -224,6 +224,9 @@ static int configure_superblock(struct libmnt_context *cxt,
|
||||||
|
/* Ignore VFS flags, userspace and external options */
|
||||||
|
continue;
|
||||||
|
|
||||||
|
+ if (!value && mnt_opt_is_sepnodata(opt))
|
||||||
|
+ value = ""; /* force use the value as string */
|
||||||
|
+
|
||||||
|
rc = fsconfig_set_value(cxt, hs, fd, name, value);
|
||||||
|
if (rc != 0)
|
||||||
|
goto done;
|
||||||
|
diff --git a/libmount/src/mountP.h b/libmount/src/mountP.h
|
||||||
|
index 458aa1a00..fcc40bffc 100644
|
||||||
|
--- a/libmount/src/mountP.h
|
||||||
|
+++ b/libmount/src/mountP.h
|
||||||
|
@@ -608,6 +608,7 @@ extern int mnt_opt_set_value(struct libmnt_opt *opt, const char *str);
|
||||||
|
extern int mnt_opt_set_u64value(struct libmnt_opt *opt, uint64_t num);
|
||||||
|
extern int mnt_opt_set_quoted_value(struct libmnt_opt *opt, const char *str);
|
||||||
|
extern int mnt_opt_is_external(struct libmnt_opt *opt);
|
||||||
|
+extern int mnt_opt_is_sepnodata(struct libmnt_opt *opt);
|
||||||
|
|
||||||
|
/* fs.c */
|
||||||
|
extern int mnt_fs_follow_optlist(struct libmnt_fs *fs, struct libmnt_optlist *ol);
|
||||||
|
diff --git a/libmount/src/optlist.c b/libmount/src/optlist.c
|
||||||
|
index 101c908ae..476acfd65 100644
|
||||||
|
--- a/libmount/src/optlist.c
|
||||||
|
+++ b/libmount/src/optlist.c
|
||||||
|
@@ -46,6 +46,7 @@ struct libmnt_opt {
|
||||||
|
|
||||||
|
unsigned int external : 1, /* visible for external helpers only */
|
||||||
|
recursive : 1, /* recursive flag */
|
||||||
|
+ sepnodata : 1, /* value separator, but without data ("name=") */
|
||||||
|
is_linux : 1, /* defined in ls->linux_map (VFS attr) */
|
||||||
|
quoted : 1; /* name="value" */
|
||||||
|
};
|
||||||
|
@@ -438,6 +439,10 @@ static struct libmnt_opt *optlist_new_opt(struct libmnt_optlist *ls,
|
||||||
|
opt->value = strndup(value, valsz);
|
||||||
|
if (!opt->value)
|
||||||
|
goto fail;
|
||||||
|
+
|
||||||
|
+ } else if (value) {
|
||||||
|
+ /* separator specified, but empty value ("name=") */
|
||||||
|
+ opt->sepnodata = 1;
|
||||||
|
}
|
||||||
|
if (namesz) {
|
||||||
|
opt->name = strndup(name, namesz);
|
||||||
|
@@ -957,7 +962,8 @@ int mnt_optlist_strdup_optstr(struct libmnt_optlist *ls, char **optstr,
|
||||||
|
continue;
|
||||||
|
rc = mnt_buffer_append_option(&buf,
|
||||||
|
opt->name, strlen(opt->name),
|
||||||
|
- opt->value,
|
||||||
|
+ opt->value ? opt->value :
|
||||||
|
+ opt->sepnodata ? "" : NULL,
|
||||||
|
opt->value ? strlen(opt->value) : 0,
|
||||||
|
opt->quoted);
|
||||||
|
if (rc)
|
||||||
|
@@ -1043,6 +1049,7 @@ struct libmnt_optlist *mnt_copy_optlist(struct libmnt_optlist *ls)
|
||||||
|
no->src = opt->src;
|
||||||
|
no->external = opt->external;
|
||||||
|
no->quoted = opt->quoted;
|
||||||
|
+ no->sepnodata = opt->sepnodata;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1184,6 +1191,11 @@ int mnt_opt_is_external(struct libmnt_opt *opt)
|
||||||
|
return opt && opt->external ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+int mnt_opt_is_sepnodata(struct libmnt_opt *opt)
|
||||||
|
+{
|
||||||
|
+ return opt->sepnodata;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
|
||||||
|
#ifdef TEST_PROGRAM
|
||||||
|
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
104
backport-libmount-use-some-MS_-flags-as-superblock-flags.patch
Normal file
104
backport-libmount-use-some-MS_-flags-as-superblock-flags.patch
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
From 54e4a6b145fd6ef943d93e16de748283e687855d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Karel Zak <kzak@redhat.com>
|
||||||
|
Date: Thu, 20 Jul 2023 12:34:14 +0200
|
||||||
|
Subject: [PATCH] libmount: use some MS_* flags as superblock flags
|
||||||
|
|
||||||
|
The old mount(2) API usually utilizes MS_* flags to set up the VFS
|
||||||
|
node. However, there are some exceptions like "sync" (MS_SYNCHRONOUS),
|
||||||
|
where the flag is used (by kernel) for the superblock instead. The new
|
||||||
|
API addresses this issue, ensuring that these options are used for
|
||||||
|
fsconfig().
|
||||||
|
|
||||||
|
This commit introduces MNT_SUPERBLOCK to identify these options in the
|
||||||
|
libmount options Linux map, and it enforces the new mount code to
|
||||||
|
utilize these options for fsconfig(FSCONFIG_SET_FLAG).
|
||||||
|
|
||||||
|
Reported-by: Abbink Esger <esger.abbink.ext@siemens.com>
|
||||||
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
||||||
|
---
|
||||||
|
libmount/src/hook_mount.c | 11 +++++++++--
|
||||||
|
libmount/src/libmount.h.in | 1 +
|
||||||
|
libmount/src/optmap.c | 14 +++++++-------
|
||||||
|
3 files changed, 17 insertions(+), 9 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libmount/src/hook_mount.c b/libmount/src/hook_mount.c
|
||||||
|
index 77a7bed30..ed4ec349c 100644
|
||||||
|
--- a/libmount/src/hook_mount.c
|
||||||
|
+++ b/libmount/src/hook_mount.c
|
||||||
|
@@ -154,12 +154,19 @@ static int configure_superblock(struct libmnt_context *cxt,
|
||||||
|
const char *name = mnt_opt_get_name(opt);
|
||||||
|
const char *value = mnt_opt_get_value(opt);
|
||||||
|
const struct libmnt_optmap *ent = mnt_opt_get_mapent(opt);
|
||||||
|
+ const int is_linux = ent && mnt_opt_get_map(opt) == cxt->map_linux;
|
||||||
|
|
||||||
|
- if (ent && mnt_opt_get_map(opt) == cxt->map_linux &&
|
||||||
|
- ent->id == MS_RDONLY) {
|
||||||
|
+ if (is_linux && ent->id == MS_RDONLY) {
|
||||||
|
+ /* Use ro/rw for superblock (for backward compatibility) */
|
||||||
|
value = NULL;
|
||||||
|
has_rwro = 1;
|
||||||
|
+
|
||||||
|
+ } else if (is_linux && ent->mask & MNT_SUPERBLOCK) {
|
||||||
|
+ /* Use some old MS_* (VFS) flags as superblock flags */
|
||||||
|
+ ;
|
||||||
|
+
|
||||||
|
} else if (!name || mnt_opt_get_map(opt) || mnt_opt_is_external(opt))
|
||||||
|
+ /* Ignore VFS flags, userspace and external options */
|
||||||
|
continue;
|
||||||
|
|
||||||
|
rc = fsconfig_set_value(cxt, hs, fd, name, value);
|
||||||
|
diff --git a/libmount/src/libmount.h.in b/libmount/src/libmount.h.in
|
||||||
|
index f156483b6..06c27047d 100644
|
||||||
|
--- a/libmount/src/libmount.h.in
|
||||||
|
+++ b/libmount/src/libmount.h.in
|
||||||
|
@@ -89,6 +89,7 @@ struct libmnt_optmap
|
||||||
|
#define MNT_PREFIX (1 << 3) /* prefix used for some options (e.g. "x-foo") */
|
||||||
|
#define MNT_NOHLPS (1 << 4) /* don't add the option to mount.<type> helpers command line */
|
||||||
|
#define MNT_NOFSTAB (1 << 5) /* not expected in fstab */
|
||||||
|
+#define MNT_SUPERBLOCK (1 << 6) /* MS_* for mount(2), otherwise requires fsconfig() */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* libmnt_fs:
|
||||||
|
diff --git a/libmount/src/optmap.c b/libmount/src/optmap.c
|
||||||
|
index 3a91f30d4..d7569a0f0 100644
|
||||||
|
--- a/libmount/src/optmap.c
|
||||||
|
+++ b/libmount/src/optmap.c
|
||||||
|
@@ -79,10 +79,10 @@ static const struct libmnt_optmap linux_flags_map[] =
|
||||||
|
{ "dev", MS_NODEV, MNT_INVERT }, /* interpret device files */
|
||||||
|
{ "nodev", MS_NODEV }, /* don't interpret devices */
|
||||||
|
|
||||||
|
- { "sync", MS_SYNCHRONOUS }, /* synchronous I/O */
|
||||||
|
- { "async", MS_SYNCHRONOUS, MNT_INVERT },/* asynchronous I/O */
|
||||||
|
+ { "sync", MS_SYNCHRONOUS, MNT_SUPERBLOCK }, /* synchronous I/O */
|
||||||
|
+ { "async", MS_SYNCHRONOUS, MNT_INVERT | MNT_SUPERBLOCK },/* asynchronous I/O */
|
||||||
|
|
||||||
|
- { "dirsync", MS_DIRSYNC }, /* synchronous directory modifications */
|
||||||
|
+ { "dirsync", MS_DIRSYNC, MNT_SUPERBLOCK },/* synchronous directory modifications */
|
||||||
|
{ "remount", MS_REMOUNT, MNT_NOMTAB }, /* alter flags of mounted FS */
|
||||||
|
{ "bind", MS_BIND }, /* Remount part of the tree elsewhere */
|
||||||
|
{ "rbind", MS_BIND | MS_REC }, /* Idem, plus mounted subtrees */
|
||||||
|
@@ -95,8 +95,8 @@ static const struct libmnt_optmap linux_flags_map[] =
|
||||||
|
{ "loud", MS_SILENT, MNT_INVERT }, /* print out messages. */
|
||||||
|
#endif
|
||||||
|
#ifdef MS_MANDLOCK
|
||||||
|
- { "mand", MS_MANDLOCK }, /* Allow mandatory locks on this FS */
|
||||||
|
- { "nomand", MS_MANDLOCK, MNT_INVERT }, /* Forbid mandatory locks on this FS */
|
||||||
|
+ { "mand", MS_MANDLOCK, MNT_SUPERBLOCK }, /* Allow mandatory locks on this FS */
|
||||||
|
+ { "nomand", MS_MANDLOCK, MNT_INVERT | MNT_SUPERBLOCK}, /* Forbid mandatory locks on this FS */
|
||||||
|
#endif
|
||||||
|
#ifdef MS_NOATIME
|
||||||
|
{ "atime", MS_NOATIME, MNT_INVERT }, /* Update access time */
|
||||||
|
@@ -119,8 +119,8 @@ static const struct libmnt_optmap linux_flags_map[] =
|
||||||
|
{ "nostrictatime", MS_STRICTATIME, MNT_INVERT }, /* kernel default atime */
|
||||||
|
#endif
|
||||||
|
#ifdef MS_LAZYTIME
|
||||||
|
- { "lazytime", MS_LAZYTIME }, /* Update {a,m,c}time on the in-memory inode only */
|
||||||
|
- { "nolazytime", MS_LAZYTIME, MNT_INVERT },
|
||||||
|
+ { "lazytime", MS_LAZYTIME, MNT_SUPERBLOCK }, /* Update {a,m,c}time on the in-memory inode only */
|
||||||
|
+ { "nolazytime", MS_LAZYTIME, MNT_INVERT | MNT_SUPERBLOCK },
|
||||||
|
#endif
|
||||||
|
#ifdef MS_PROPAGATION
|
||||||
|
{ "unbindable", MS_UNBINDABLE, MNT_NOHLPS | MNT_NOMTAB }, /* Unbindable */
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
Name: util-linux
|
Name: util-linux
|
||||||
Version: 2.39.1
|
Version: 2.39.1
|
||||||
Release: 8
|
Release: 9
|
||||||
Summary: A random collection of Linux utilities
|
Summary: A random collection of Linux utilities
|
||||||
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://git.kernel.org/pub/scm/utils/util-linux/util-linux.git
|
URL: https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git
|
||||||
@ -31,6 +31,13 @@ Patch6009: backport-tests-test_mkfds-netlink-pass-a-correct-file-descrip.pa
|
|||||||
Patch6010: backport-tests-functions.sh-add-a-helper-funcion-making-a-dev.patch
|
Patch6010: backport-tests-functions.sh-add-a-helper-funcion-making-a-dev.patch
|
||||||
Patch6011: backport-tests-lsfd-don-t-refer-on-the-line-follwoing-the-use.patch
|
Patch6011: backport-tests-lsfd-don-t-refer-on-the-line-follwoing-the-use.patch
|
||||||
Patch6012: backport-lsfd-fix-memory-leak-in-append_filter_expr.patch
|
Patch6012: backport-lsfd-fix-memory-leak-in-append_filter_expr.patch
|
||||||
|
Patch6013: backport-libmount-use-some-MS_-flags-as-superblock-flags.patch
|
||||||
|
Patch6014: backport-libmount-Fix-regression-when-mounting-with-atime.patch
|
||||||
|
Patch6015: backport-libmount-ifdef-statx-call.patch
|
||||||
|
Patch6016: backport-libmount-improve-mnt_table_next_child_fs.patch
|
||||||
|
Patch6017: backport-libmount-make-sure-option-is-used-as-string.patch
|
||||||
|
Patch6018: backport-libmount-fix-possible-memory-leak.patch
|
||||||
|
Patch6019: backport-libmount-Fix-atime-remount-for-new-API.patch
|
||||||
|
|
||||||
Patch9000: SKIPPED-no-root-permissions-test.patch
|
Patch9000: SKIPPED-no-root-permissions-test.patch
|
||||||
%ifarch sw_64
|
%ifarch sw_64
|
||||||
@ -417,6 +424,12 @@ fi
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Jul 3 2024 zhangyao <zhangyao108@huawei.com> - 2.39.1-9
|
||||||
|
- Type:bugfix
|
||||||
|
- CVE:NA
|
||||||
|
- SUG:NA
|
||||||
|
- DESC:sync community patches
|
||||||
|
|
||||||
* Sat May 11 2024 zhangyao <zhangyao108@huawei.com> - 2.39.1-8
|
* Sat May 11 2024 zhangyao <zhangyao108@huawei.com> - 2.39.1-8
|
||||||
- Type:bugfix
|
- Type:bugfix
|
||||||
- CVE:NA
|
- CVE:NA
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user