Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1806514

Summary: strictexpire option not set for offset mounts
Product: Red Hat Enterprise Linux 7 Reporter: Roberto Bergantinos <rbergant>
Component: autofsAssignee: Ian Kent <ikent>
Status: CLOSED ERRATA QA Contact: Kun Wang <kunwan>
Severity: high Docs Contact:
Priority: unspecified    
Version: 7.6CC: ikent, xzhou
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: autofs-5.0.7-110.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-09-29 19:56:37 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
add strictexpire for offset mount case
none
Patch - also use strictexpire for offsets
none
Patch - fix autofs mount options construction none

Description Roberto Bergantinos 2020-02-24 12:23:02 UTC
Created attachment 1665391 [details]
add strictexpire for offset mount case

Description of problem:

offset mounts does not "inherit" strictexpire option from root mount

[root@rhel76-2 ~]# rpm -qa autofs ; uname -r
autofs-5.0.7-106.el7.x86_64
3.10.0-1062.4.1.el7.x86_64

[root@rhel76-2 ~]# grep strict /etc/auto.master
/hosts	/etc/auto.net 	intr,proto=tcp,rw strictexpire 

[root@rhel76-2 ~]# systemctl start autofs
[root@rhel76-2 ~]# cd /hosts/rhel73
[root@rhel76-2 rhel73]# grep autofs /proc/mounts 
systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=32,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=834 0 0
/etc/auto.misc /misc autofs rw,relatime,fd=5,pgrp=3471,timeout=300,minproto=5,maxproto=5,indirect,pipe_ino=177968 0 0
/etc/auto.net /hosts autofs rw,relatime,fd=11,pgrp=3471,timeout=300,minproto=5,maxproto=5,indirect,strictexpire,pipe_ino=179016 0 0
/etc/auto.net /hosts/rhel73/5GBshare autofs rw,relatime,fd=11,pgrp=3471,timeout=300,minproto=5,maxproto=5,offset,pipe_ino=179016 0 0  <<--- no strictexpire
/etc/auto.net /hosts/rhel73/5GBshare2 autofs rw,relatime,fd=11,pgrp=3471,timeout=300,minproto=5,maxproto=5,offset,pipe_ino=179016 0 0 <<--- no strictexpire

this may impact customers where path_walks may refresh /hosts automounts leading to a very long
listing of filesystems that may not be unmounted if something scans /hosts paths periodically

checking a bit source code i propose the following trivial patch, borrowing strictexpire checking
code from do_mount_autofs_direct/indirect 

From 6975a0ce549621ef75cf863e4bc344da97ca29b9 Mon Sep 17 00:00:00 2001
From: Roberto Bergantinos Corpas <rbergant>
Date: Mon, 24 Feb 2020 12:34:24 +0100
Subject: [PATCH] adding strictexpire for offset mount case

---
 daemon/direct.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/daemon/direct.c b/daemon/direct.c
index 7aa70e9..47fb247 100644
--- a/daemon/direct.c
+++ b/daemon/direct.c
@@ -739,6 +739,16 @@ int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, const char *
 		mp->options = make_options_string(ap->path, ap->kpipefd, str_offset);
 		if (!mp->options)
 			return MOUNT_OFFSET_OK;
+
+		if ((ap->flags & MOUNT_FLAG_STRICTEXPIRE) &&
+		    ((get_kver_major() == 5 && get_kver_minor() > 3) ||
+		     (get_kver_major() > 5))) {
+			char *tmp = realloc(mp->options, strlen(mp->options) + 12);
+			if (tmp) {
+				strcat(tmp, ",strictexpire");
+				mp->options = tmp;
+			}
+		}
 	}
 
 	strcpy(mountpoint, root);
-- 
2.21.0


with that, i can see how mount options are passed to kernel :

(without patch) :

[root@rhel76-2 ~]# stap -e 'probe kernel.function("autofs4_fill_super"){printf("\n%s : options : %s\n", ppfunc(), kernel_string($data))}'  &
[2] 3895
[root@rhel76-2 ~]# systemctl start autofs
autofs4_fill_super : options : fd=4,pgrp=4185,minproto=3,maxproto=5

autofs4_fill_super : options : fd=5,pgrp=4185,minproto=5,maxproto=5,indirect

autofs4_fill_super : options : fd=11,pgrp=4185,minproto=5,maxproto=5,indirect,strictexpire

[root@rhel76-2 ~]# cd /hosts/rhel73
[root@rhel76-2 rhel73]# 
autofs4_fill_super : options : fd=11,pgrp=4185,minproto=5,maxproto=5,offset

autofs4_fill_super : options : fd=11,pgrp=4185,minproto=5,maxproto=5,offset


(with patch) :


[root@rhel76-2 ~]# stap -e 'probe kernel.function("autofs4_fill_super"){printf("\n%s : options : %s\n", ppfunc(), kernel_string($data))}'  &
[1] 4310
[root@rhel76-2 ~]# systemctl start autofs

autofs4_fill_super : options : fd=4,pgrp=4322,minproto=3,maxproto=5
[root@rhel76-2 ~]# 
autofs4_fill_super : options : fd=5,pgrp=4322,minproto=5,maxproto=5,indirect

autofs4_fill_super : options : fd=11,pgrp=4322,minproto=5,maxproto=5,indirect,strictexpire

[root@rhel76-2 ~]# cd /hosts/rhel73
[root@rhel76-2 rhel73]# 
autofs4_fill_super : options : fd=11,pgrp=4322,minproto=5,maxproto=5,offset,strictexpire <<<----

autofs4_fill_super : options : fd=11,pgrp=4322,minproto=5,maxproto=5,offset,strictexpire <<<----



Version-Release number of selected component (if applicable):


How reproducible: 100%


Steps to Reproduce:
1. see above
2.
3.

Actual results: option "strictexpire" not inherited


Expected results: option "strictexpire" inherited


Additional info::

Comment 3 Ian Kent 2020-02-25 00:37:09 UTC
(In reply to Roberto Bergantinos from comment #0)
> Created attachment 1665391 [details]
> add strictexpire for offset mount case
> 
> Description of problem:
> 
> offset mounts does not "inherit" strictexpire option from root mount

Yes, you are right, a path essentially identical to what you have
posted went into autofs 5.1.6.

Ian

Comment 7 Ian Kent 2020-02-25 02:21:54 UTC
Created attachment 1665545 [details]
Patch - also use strictexpire for offsets

Comment 8 Ian Kent 2020-02-25 04:00:59 UTC
Reading through the case notes I see there was some concern about autofs
mounting trigger mounts.

This is normal and is required in order to not have to mount all the
actual NFS exports from a remote server. The only way I'm able to
mount (and expire) only the remote NFS mounts that are accessed/used
is to use autofs trigger mounts as you can see from your investigation.
Long ago this type of autofs mount would mount "all" the actual NFS
exports and would have to leave them all mounted until "all" the mounts
were no longer in use and had passed the timeout.

You are quite right though, path walks will keep those offset mounts
mounted and that is an omission from bug 1640448.

Comment 25 Ian Kent 2020-06-15 00:26:59 UTC
Created attachment 1697280 [details]
Patch - fix autofs mount options construction

Comment 27 errata-xmlrpc 2020-09-29 19:56:37 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (autofs bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:3928