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 2211760 - Problem becoming administrator Cockpit-bridge: recvmsg(stdin) failed: Resource temporarily unavailable
Summary: Problem becoming administrator Cockpit-bridge: recvmsg(stdin) failed: Resourc...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: cockpit
Version: 9.2
Hardware: Unspecified
OS: Linux
medium
medium
Target Milestone: rc
: 9.3
Assignee: Martin Pitt
QA Contact: Jan Ščotka
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-06-01 20:50 UTC by Stephanie
Modified: 2023-11-07 10:15 UTC (History)
3 users (show)

Fixed In Version: cockpit-296-1.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-11-07 08:38:39 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
cockpit-error (16.69 KB, image/png)
2023-06-01 20:50 UTC, Stephanie
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Github cockpit-project cockpit issues 17412 0 None open Enabling sudo log_output breaks privilege escalation in Cockpit 2023-07-11 08:06:42 UTC
Github cockpit-project cockpit pull 18915 0 None open common: ensure blocking socket when receiving an fd over socket passing 2023-07-11 08:06:42 UTC
Red Hat Issue Tracker RHEL-1521 0 None None None 2023-08-21 09:33:18 UTC
Red Hat Issue Tracker RHELPLAN-158832 0 None None None 2023-06-01 20:56:22 UTC
Red Hat Product Errata RHBA-2023:6591 0 None None None 2023-11-07 08:38:46 UTC

Description Stephanie 2023-06-01 20:50:18 UTC
Created attachment 1968416 [details]
cockpit-error

Description of problem:

Local users, or AD users are receiving the bellow error when trying to become administrators thru Cocpkit 

Problem becoming administrator
Cockpit-bridge: recvmsg(stdin) failed: Resource temporarily unavailable

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

cockpit-bridge-286.1-1.el9.x86_64 

How reproducible: 

I wasn't able to reproduce it in a lab.

Steps to Reproduce:

1. Login with a non-root user

2. Try to become an administrator

Actual results:

Problem becoming administrator
Cockpit-bridge: recvmsg(stdin) failed: Resource temporarily unavailable

Expected results:

Get administrative access on cockpit.

Additional info:

Comment 1 Martin Pitt 2023-06-02 07:12:51 UTC
I debugged this a bit with Stephanie yesterday.

The root bridge does a recvfrom() to receive a file descriptor through a Unix socketpair() from the user bridge. This socket is expected to be blocking (as every opened fd is on Unix by default). But on the customer system, recvfrom() fails with EAGAIN, which means that there is no data yet, and instead of waiting for data to arrive, it fails with that error code (shown in the screenshot as "temporarily unavailable"). The bridge is not prepared for EAGAIN, as that should never happen with a normal socket pair. Something on the customer's system causes this, and I have no idea what.

My first hack was to loop recvfrom() until it stops EAGAINing. This is a ridiculous hack, but at least proves what happens. The customer confirmed that this fixed the issue. But of course it's prone to spinning 100% CPU.

The next iteration would try to set the socket back to blocking mode:

--- src/common/cockpitfdpassing.c
+++ src/common/cockpitfdpassing.c
@@ -23,6 +23,8 @@
 
 #include <assert.h>
 #include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
 #include <string.h>
 #include <unistd.h>
 
@@ -119,6 +121,13 @@ cockpit_socket_receive_fd (int  socket_fd,
                         .msg_controllen = CMSG_LEN (sizeof *out_fd) };
   assert (msg.msg_controllen <= sizeof cmsg);
 
+  int cur_flags = fcntl (socket_fd, F_GETFL);
+  if (cur_flags & O_NONBLOCK)
+    {
+      // fprintf (stderr, "cockpit_socket_receive_fd: socket_fd %i is unexpectedly non-blocking, flags %x, switching to blocking", socket_fd, cur_flags);
+      fcntl (socket_fd, F_SETFL, cur_flags & ~O_NONBLOCK);
+    }
+
   ssize_t s;
   do
     s = recvmsg (socket_fd, &msg, 0);

If this works, that would be a much better fix/workaround, as it avoids looping in user space. I sent an RPM to Stephanie for the customer to test. Once they confirm, I'm happy to send an upstream PR to fix that.

Thanks!

Comment 3 Martin Pitt 2023-06-12 08:06:06 UTC
Thanks Stephanie for confirming! I sent https://github.com/cockpit-project/cockpit/pull/18915 to fix this upstream, and eventually in RHEL 9.

Comment 4 Martin Pitt 2023-07-04 06:17:08 UTC
I already asked that in the support case, but that was closed by now.

We still don't know about the root cause of that. Dear original reporter, can you please share how you set up this system? There must be something out of the ordinary, stderr shouldn't just randomly become blocking. Custom kernel, logging into a remote system, session recording, non-default PAM libraries, etc.

Comment 5 Martin Pitt 2023-07-11 08:34:45 UTC
I can now reproduce this, see https://github.com/cockpit-project/cockpit/pull/18915 . For me this happens when enabling sudo's `log_output` option. We still don't know if it was the same root cause for the original reporter here, but that doesn't matter much now.

Comment 12 servicesredhat 2023-09-04 12:21:56 UTC
on Tumbleweed i get such message in the dbus strace:
1468  recvmsg(27, {msg_namelen=0}, MSG_CMSG_CLOEXEC) = -1 EAGAIN (Resource temporarily unavailable)

No logging turned on in sudo, or anything special. Normal journal log:

dbus-daemon[1468]: [system] Activating via systemd: service name='org.freedesktop.hostname1' unit='dbus-org.freedesktop.hostname1.service' requested by ':1.816' (uid=1000 pid=22597 comm="cockpit-bridge")
systemd[1]: Starting Hostname Service...
dbus-daemon[1468]: [system] Successfully activated service 'org.freedesktop.hostname1'
systemd[1]: Started Hostname Service.
dbus-daemon[1468]: [system] Activating via systemd: service name='org.freedesktop.timedate1' unit='dbus-org.freedesktop.timedate1.service' requested by ':1.819' (uid=1000 pid=22597 comm="cockpit-bridge")
systemd[1]: Starting Time & Date Service...
dbus-daemon[1468]: [system] Successfully activated service 'org.freedesktop.timedate1'
systemd[1]: Started Time & Date Service.
dbus-daemon[1468]: [system] Activating via systemd: service name='org.freedesktop.PackageKit' unit='packagekit.service' requested by ':1.823' (uid=0 pid=22606 comm="cockpit-bridge --privileged")
systemd[1]: Starting PackageKit Daemon...
PackageKit[22755]: daemon start
dbus-daemon[1468]: [system] Successfully activated service 'org.freedesktop.PackageKit'
systemd[1]: Started PackageKit Daemon.

After restart of libvirt-dbus admin can access VMs in cockpit immediately.

Comment 14 errata-xmlrpc 2023-11-07 08:38:39 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 (cockpit 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:6591


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