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 1792173 - Ordering cycle introduced by tangd.socket during boot
Summary: Ordering cycle introduced by tangd.socket during boot
Keywords:
Status: CLOSED DUPLICATE of bug 1679186
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: tang
Version: 8.1
Hardware: All
OS: Linux
high
high
Target Milestone: rc
: 8.0
Assignee: Sergio Correia
QA Contact: BaseOS QE Security Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-01-17 08:23 UTC by Renaud Métrich
Modified: 2023-12-15 17:11 UTC (History)
2 users (show)

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


Attachments (Terms of Use)
Proposed updated tangd units (10.00 KB, patch)
2020-01-17 08:38 UTC, Renaud Métrich
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Github latchset tang pull 42 0 None closed Fixed Ordering cycle found, causing spurious issues during boot (no tangd.socket enabled, or no network, etc.) 2021-01-19 09:04:23 UTC
Red Hat Knowledge Base (Solution) 4740311 0 None None None 2020-01-17 09:18:20 UTC

Description Renaud Métrich 2020-01-17 08:23:49 UTC
Description of problem:

When enabling tangd.socket on a RHEL8 system, an ordering cycle is created (and deleted) at boot, causing various issues around "sockets.target" to happen, usually "tangd.socket" gets not started:

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
[...] sockets.target: Found ordering cycle on tangd.socket/start
[...] sockets.target: Found dependency on tangd-keygen.service/start
[...] sockets.target: Found dependency on basic.target/start
[...] sockets.target: Found dependency on sockets.target/start
[...] sockets.target: Job tangd.socket/start deleted to break ordering cycle starting with sockets.target/start
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

The reason behind this is "tangd.socket" requires "tangd-keygen.service" which itself must start after "basic.target" (it's the default dependencies for services), but this cannot happen because "sockets.target" is supposed to be reached before "basic.target".

The exact same unit files on RHEL7 do not produce this ordering cycle, even though they should in theory.

There are hence 2 issues there:

(Issue 1). something must have changed in systemd-239 compared to systemd-219 (RHEL7), causing "sockets.target" to pull "tangd.socket" even though "tangd.socket" is installed in "multi-user.target"

(Issue 2). the tangd.socket unit must be fixed, it is quite non-sense to have a socket depend on service units (a socket is just "idle" until used)


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

tang-7-1.el8.x86_64, also applies to Upstream tang probably (at least applies to tang-7-3 which is "latest community" on Arch Linux ... running on my raspberrypi :-))


How reproducible:

This is 100% reproducible with RHEL 8.1 latest.


Steps to Reproduce:
1. Install tang

  # yum -y install tang

2. Enable the socket

  # systemctl enable tangd.socket

3. Reboot

Actual results:

Ordering cycle broken for sockets.target


Expected results:

No ordering cycle


Additional info:

(Issue 1) related to systemd will be investigated in another BZ.

(Issue 2) proposed fix in comment to follow.

Comment 1 Renaud Métrich 2020-01-17 08:35:08 UTC
Currently, we have "tangd.socket" require/after "tangd-keygen.service" and "tangd-update.service". Additionally the socket is installed in "multi-user.target":

/usr/lib/systemd/system/tangd.socket:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
[Unit]
Description=Tang Server socket
Requires=tangd-keygen.service
Requires=tangd-update.service
Requires=tangd-update.path
After=tangd-keygen.service
After=tangd-update.service

[Socket]
ListenStream=80
Accept=true

[Install]
WantedBy=multi-user.target
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

It looks weird to me that a *socket* depends on *services* or *paths*.
Due to having a socket, we have systemd automatically add a "After" dependency on "sockets.target" (this is Issue 1 to be investigate), which creates the ordering cycle.
For some reason, the same dependency was happening on RHEL7 but didn't create an ordering cycle.

To fix all this, I propose the following changes:

1. Implement a "regular" socket, installed in "sockets.target" with no dependencies

/usr/lib/systemd/system/tangd.socket:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
[Unit]
Description=Tang Server socket

[Socket]
ListenStream=80
Accept=true

[Install]
WantedBy=sockets.target
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

2. Move the dependencies in "tangd@.service" unit which is where dependencies have to be handled

/usr/lib/systemd/system/tangd@.service:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
[Unit]
Description=Tang Server
Requires=tangd-keygen.service
After=tangd-keygen.service

[Service]
StandardInput=socket
StandardOutput=socket
StandardError=journal
ExecStart=/usr/libexec/tangd /var/cache/tang
User=tang
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Note here that I removed the dependency on "tangd-update.path" and "tangd-update.service" since I consider that they are not needed at all:
- tangd-update.path monitors changes in Tang keys, this has nothing to do with "tangd@.service" instances
- tangd-update.service updates the cache with new keys, this has nothing to do with "tangd@.service" instances either

Please correct me if I'm wrong with the logic.

With this in place, the ordering cycle just disappear, "tangd.socket" becomes a regular socket, and, when it triggers an instance of "tangd@.service", systemd will check that there is indeed Tang keys to use.

Note for packaging: the postinstall RPM scriptlet should re-enable the socket upon package upgrade since it moved from "multi-user.target" to "sockets.target".

Comment 2 Renaud Métrich 2020-01-17 08:38:59 UTC
Created attachment 1652978 [details]
Proposed updated tangd units

Comment 3 Renaud Métrich 2020-01-17 10:28:29 UTC
Issue 1 is tracked by BZ #1792219


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