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 2169063 - systemd: Failed to set up mount namespacing: File exists when using StateDirectory, LogsDirectory with RootDirectory and DynamicUser=true
Summary: systemd: Failed to set up mount namespacing: File exists when using StateDire...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: systemd
Version: 9.1
Hardware: All
OS: Linux
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: systemd-maint
QA Contact: Frantisek Sumsal
URL:
Whiteboard:
Depends On: 2138081
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-02-11 14:20 UTC by Ernesto Castellotti
Modified: 2023-05-09 10:34 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-05-09 08:22:35 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github systemd systemd issues 22264 0 None closed systemd-portabled: Failed to set up mount namespacing: File exists when using StateDirectory, LogsDirectory, etc 2023-02-11 14:20:31 UTC
Github systemd systemd pull 22272 0 None Merged core: do not attempt to add 'private' symlinks when RootImage/RootDirectory are used 2023-02-11 14:20:31 UTC
Red Hat Issue Tracker RHELPLAN-148356 0 None None None 2023-02-11 14:20:49 UTC
Red Hat Product Errata RHBA-2023:2531 0 None None None 2023-05-09 08:22:52 UTC

Description Ernesto Castellotti 2023-02-11 14:20:31 UTC
Description of problem:
Systemd fails to mount namespace when using RootDirectory=some_ath, DynamicUser=true and StateDirectory, LogsDirectory etc.
This issue was already reported to systemd upstream (https://github.com/systemd/systemd/issues/22264) and they made a patch to fix it (https://github.com/systemd/systemd/pull/22272), however it has not currently been backported to the systemd package used by RHEL 9.1.

Version-Release number of selected component (if applicable): 250-12.el9_1.1





Steps to Reproduce:
1. wget https://dl-cdn.alpinelinux.org/alpine/v3.17/releases/x86_64/alpine-minirootfs-3.17.2-x86_64.tar.gz -O /tmp/rootfs.tar.gz
2. mkdir /tmp/rootfs && tar xf /tmp/rootfs.tar.gz -C /tmp/rootfs
3. chcon -R -t bin_t /tmp/rootfs/bin
4. chcon -R -t lib_t /tmp/rootfs/lib
5. sudo systemctl daemon-reload
6. sudo systemctl start test
7. systemctl status test

Content of unit test.service:
[Service]
DynamicUser=true
StateDirectory=foo
RootDirectory=/tmp/rootfs
ExecStart=/bin/cat /etc/os-release





Actual results:
× test.service
     Loaded: loaded (/etc/systemd/system/test.service; static)
     Active: failed (Result: exit-code) since Sat 2023-02-11 15:10:41 CET; 2s ago
   Duration: 4ms
    Process: 3468 ExecStart=/bin/cat /etc/os-release (code=exited, status=226/NAMESPACE)
   Main PID: 3468 (code=exited, status=226/NAMESPACE)
        CPU: 3ms

feb 11 15:10:41 lpc-machine systemd[1]: Started test.service.
feb 11 15:10:41 lpc-machine systemd[3468]: test.service: Failed to set up mount namespacing: File exists
feb 11 15:10:41 lpc-machine systemd[3468]: test.service: Failed at step NAMESPACE spawning /bin/cat: File exists
feb 11 15:10:41 lpc-machine systemd[1]: test.service: Main process exited, code=exited, status=226/NAMESPACE
feb 11 15:10:41 lpc-machine systemd[1]: test.service: Failed with result 'exit-code'





Expected results:
○ test.service
     Loaded: loaded (/etc/systemd/system/test.service; static)
     Active: inactive (dead)

feb 11 15:05:19 lpc-machine cat[10778]: 
feb 11 15:06:38 lpc-machine systemd[1]: Started test.service.
feb 11 15:06:38 lpc-machine cat[10856]: NAME="Alpine Linux"
feb 11 15:06:38 lpc-machine cat[10856]: ID=alpine
feb 11 15:06:38 lpc-machine cat[10856]: VERSION_ID=3.17.2
feb 11 15:06:38 lpc-machine cat[10856]: PRETTY_NAME="Alpine Linux v3.17"
feb 11 15:06:38 lpc-machine cat[10856]: HOME_URL="https://alpinelinux.org/"
feb 11 15:06:38 lpc-machine cat[10856]: BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"
feb 11 15:06:38 lpc-machine systemd[1]: test.service: Deactivated successfully.






Additional info:
I was able to patch the systemd RPM package source used by RHEL and compile the systemd RPM package solving the issue, it would be helpful to update the RHEL 9 systemd package with the addition of the patch (https://github.com/systemd/systemd/pull/22272)

Comment 3 errata-xmlrpc 2023-05-09 08:22:35 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 (systemd 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-2023:2531


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