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 1748840 - script generated by systemd-fstab-generator which is mounting a plain file under /tmp can start tmp.mount
Summary: script generated by systemd-fstab-generator which is mounting a plain file un...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: systemd
Version: 8.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 8.2
Assignee: David Tardon
QA Contact: Frantisek Sumsal
URL:
Whiteboard:
: 1653207 (view as bug list)
Depends On:
Blocks: 1708794
TreeView+ depends on / blocked
 
Reported: 2019-09-04 09:30 UTC by Yongcheng Yang
Modified: 2020-11-04 02:06 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-11-04 02:02:06 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github systemd-rhel rhel-8 pull 104 0 None closed (#1748840) mount: don't add Requires for tmp.mount 2020-08-15 11:53:20 UTC
Red Hat Product Errata RHSA-2020:4553 0 None None None 2020-11-04 02:02:39 UTC

Description Yongcheng Yang 2019-09-04 09:30:37 UTC
Description of problem:
If trying to loop mount a plain file, the OS will perform `losetup` automaticly in the backgroud. And that's okay.
But if that entry is added into /etc/fstab and execute `systemctl daemon-reload`, the newly created xxx.mount script generated by systemd-fstab-generator could start tmp.mount (which is disabled by default) leading the /tmp over-mounted!

Version-Release number of selected component (if applicable):
systemd-239-17.el8.x86_64

How reproducible:
always easily

Steps to Reproduce:
0. truncate --size 1G /tmp/test_img && mkfs -t xfs /tmp/test_img && mkdir -p /test
1. echo "/tmp/test_img  /test  xfs  defaults  0 0" >> /etc/fstab
2. systemctl daemon-reload
3. systemctl start /test


Actual results:
[root.0~]# tail -1 /etc/fstab 
/tmp/test_img  /test  xfs  defaults  0 0
[root.0~]# mount /test
[root.0~]# losetup 
NAME       SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE     DIO LOG-SEC
/dev/loop0         0      0         1  0 /tmp/test_img   0     512
[root.0~]# umount /test
[root.0~]# losetup 
[root.0~]# systemctl daemon-reload
[root.0~]# systemctl cat /test/
# /run/systemd/generator/test.mount
# Automatically generated by systemd-fstab-generator

[Unit]
SourcePath=/etc/fstab
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
Before=local-fs.target

[Mount]
Where=/test
What=/tmp/test_img        <<<<<<<<<<
Type=xfs
[root.0~]# df -h /tmp
Filesystem                              Size  Used Avail Use% Mounted on
/dev/mapper/rhel_ibm--x3250m4--07-root   50G  3.2G   47G   7% / <<<<<<<<
[root.0~]# systemctl start /test/
Job for test.mount failed.
See "systemctl status test.mount" and "journalctl -xe" for details.
[root.0~]# df -h /tmp
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           1.9G     0  1.9G   0% /tmp               <<<<<<<<<<<<<<
[root.0~]# 
[root.0~]# systemctl stop tmp.mount
[root.0~]# df -h /tmp
Filesystem                              Size  Used Avail Use% Mounted on
/dev/mapper/rhel_ibm--x3250m4--07-root   50G  3.2G   47G   7% /


Expected results:
/tmp should not be over-mounted


Additional info:
 - This problem only occurs since 8.0.0 and does't reproduce in rhel7 now
 - It works if switching plain file to loop device directly
   E.g.
   ~~~~~~~~~~~~~~
   [root.0~]# systemctl daemon-reload
   [root.0~]# systemctl cat /test/
   # /run/systemd/generator/test.mount
   # Automatically generated by systemd-fstab-generator
   
   [Unit]
   SourcePath=/etc/fstab
   Documentation=man:fstab(5) man:systemd-fstab-generator(8)
   Before=local-fs.target
   
   [Mount]
   Where=/test
   What=/dev/loop0        <<<<<<<<<<<<
   Type=xfs
   [root.0~]# df -h /tmp
   Filesystem                              Size  Used Avail Use% Mounted on
   /dev/mapper/rhel_ibm--x3250m4--07-root   50G  3.2G   47G   7% /
   [root.0~]# systemctl start /test/
   [root.0~]# df -h /tmp
   Filesystem                              Size  Used Avail Use% Mounted on
   /dev/mapper/rhel_ibm--x3250m4--07-root   50G  3.2G   47G   7% /
   [root.0~]# umount /test/
   [root.0~]# 
   ~~~~~~~~~~~~~~

Comment 1 Yongcheng Yang 2019-09-04 09:35:16 UTC
*** Bug 1653207 has been marked as a duplicate of this bug. ***

Comment 2 Yongcheng Yang 2019-09-05 06:24:45 UTC
Have just checked this problem can only be triggered when mounting plain file resides in the directory /tmp/
~~~~~~~~~~~~~~~~~~~~~~~~~~~
# systemctl start /test
# df -h /tmp/
Filesystem                              Size  Used Avail Use% Mounted on
/dev/mapper/rhel_ibm--x3250m4--07-root   50G  3.2G   47G   7% /
# systemctl cat /test
# /run/systemd/generator/test.mount
# Automatically generated by systemd-fstab-generator

[Unit]
SourcePath=/etc/fstab
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
Before=local-fs.target

[Mount]
Where=/test
What=/root/test_img                            <<<<<<<<<<
Type=xfs
# losetup
NAME       SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE      DIO LOG-SEC
/dev/loop0         0      0         1  0 /root/test_img   0     512

Comment 3 David Tardon 2020-01-14 17:46:32 UTC
The result might be a bit surprising, but there is no bug here. The generator adds /root/test_img to test.mount's RequiresMountsFor= (run "systemctl show -p RequiresMountsFor test.mount" to check). Because of this and because there is an active mount unit for /tmp, tmp.mount is added to test.mount's After= when test.mount is loaded ("systemctl show -p After test.mount"). Mask tmp.mount if you don't want this.

Comment 4 David Tardon 2020-01-15 11:41:31 UTC
I didn't realize we already handle this as a special case in RHEL 7. Reopening.

Comment 5 Lukáš Nykrýn 2020-06-08 13:50:53 UTC
fix merged to github master branch -> https://github.com/systemd-rhel/rhel-8/pull/104

Comment 12 errata-xmlrpc 2020-11-04 02:02:06 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 (Low: systemd security, 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/RHSA-2020:4553


Note You need to log in before you can comment on or make changes to this bug.