autofs/SOURCES/autofs-5.1.8-fix-incorrect-path-for-is_mounted-in-try_remount.patch
2023-03-29 01:19:48 +00:00

64 lines
1.9 KiB
Diff

autofs-5.1.8 - fix incorrect path for is_mounted() in try_remount()
From: Ian Kent <raven@themaw.net>
A regression was introduced when the offset mount handling was rewritten.
It resulted in an incorrect path sometimes being used in an is_mounted()
check.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
lib/mounts.c | 26 +++++++++++++++++++++-----
2 files changed, 22 insertions(+), 5 deletions(-)
--- autofs-5.1.7.orig/CHANGELOG
+++ autofs-5.1.7/CHANGELOG
@@ -111,6 +111,7 @@
- fix deadlock with hosts map reload.
- fix memory leak in update_hosts_mounts().
- fix minus only option handling in concat_options().
+- fix incorrect path for is_mounted() in try_remount().
25/01/2021 autofs-5.1.7
- make bind mounts propagation slave by default.
--- autofs-5.1.7.orig/lib/mounts.c
+++ autofs-5.1.7/lib/mounts.c
@@ -2803,14 +2803,30 @@ int try_remount(struct autofs_point *ap,
ap->flags &= ~MOUNT_FLAG_DIR_CREATED;
else
ap->flags |= MOUNT_FLAG_DIR_CREATED;
+ goto done;
+ }
+
+ me->flags &= ~MOUNT_FLAG_DIR_CREATED;
+ /* Direct or offset mount, key is full path */
+ if (MM_PARENT(me)->key[0] == '/') {
+ if (!is_mounted(MM_PARENT(me)->key, MNTS_REAL))
+ me->flags |= MOUNT_FLAG_DIR_CREATED;
} else {
- me->flags &= ~MOUNT_FLAG_DIR_CREATED;
- if (type == t_offset) {
- if (!is_mounted(MM_PARENT(me)->key, MNTS_REAL))
- me->flags |= MOUNT_FLAG_DIR_CREATED;
+ char *p_key = MM_PARENT(me)->key;
+ char mp[PATH_MAX + 1];
+ int len;
+
+ len = mount_fullpath(mp, PATH_MAX, ap->path, ap->len, p_key);
+ if (len > PATH_MAX) {
+ /* This should never happen due to earlier checks */
+ error(ap->logopt, "mountpoint path too long");
+ return 0;
}
- }
+ if (!is_mounted(mp, MNTS_REAL))
+ me->flags |= MOUNT_FLAG_DIR_CREATED;
+ }
+done:
/*
* Either we opened the mount or we're re-reading the map.
* If we opened the mount and ioctlfd is not -1 we have