Red Hat Bugzilla – 1839753 – "Failed to reset fd limit before activating service: org.freedesktop.DBus.Error.AccessDenied: Failed to restore old fd limit: Operation not permitted" messages
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.
"Failed to reset fd limit before activating service: org.freedesktop.DBus.Error.AccessDenied: Failed to restore old fd limit: Operation not permitted" messages
Description of problem:
On RHEL 8.2 workstations, while logged in as root user, as soon as the root user executes a program that spawns a dbus service behind (e.g. "SELinux Troubleshooter"), the following message is seen in the journal, at Warning level:
"
Failed to reset fd limit before activating service: org.freedesktop.DBus.Error.AccessDenied: Failed to restore old fd limit: Operation not permitted
"
From DBus code, the message appears when DBus daemon's child tries to restore limits. This has no impact but is confusing to the users.
dbus-1.12.8/bus/activation.c:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
1711 static void
1712 child_setup (void *user_data)
1713 {
1714 #ifdef DBUS_UNIX
1715 BusActivation *activation = user_data;
1716 DBusRLimit *initial_fd_limit;
1717 DBusError error;
1718
1719 dbus_error_init (&error);
1720 initial_fd_limit = bus_context_get_initial_fd_limit (activation->context);
1721
1722 if (initial_fd_limit != NULL &&
1723 !_dbus_rlimit_restore_fd_limit (initial_fd_limit, &error))
1724 {
1725 /* unfortunately we don't actually know the service name here */
1726 bus_context_log (activation->context,
1727 DBUS_SYSTEM_LOG_WARNING,
1728 "Failed to reset fd limit before activating "
1729 "service: %s: %s",
1730 error.name, error.message);
1731 }
1732 #endif
1733 }
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
Version-Release number of selected component (if applicable):
dbus-1.12.8-9.el8.x86_64
How reproducible:
Always
Steps to Reproduce:
1. Login as the root user in the GUI
2. Execute SELinux Troubleshooter (under Sundry folder)
Actual results:
Strace of dbus daemon shows:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
3212 14:45:15.878851 prlimit64(0, RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=256*1024}, NULL) = -1 EPERM (Operation not permitted) <0.000020>
3212 14:45:15.879102 sendto(20<UNIX:[25770->6756]>, "<28>May 25 14:45:15 dbus-daemon[3212]: [system] Failed to reset fd limit before activating service: org.freedesktop.DBus.Error.AccessDenied: Failed to restore old fd limit: Operation not permitted", 196, MSG_NOSIGNAL, NULL, 0) = 196 <0.001304>
3212 14:45:15.880540 execve("//usr/libexec/dbus-1/dbus-daemon-launch-helper", ["//usr/libexec/dbus-1/dbus-daemon-launch-helper", "org.fedoraproject.Setroubleshootd"], ["DBUS_SYSTEM_BUS_ADDRESS=unix:path=/run/dbus/system_bus_socket,guid=1514dcc38e0d60fe80fc0bd85ecbbcd6", "DBUS_STARTER_BUS_TYPE=system", "JOURNAL_STREAM=9:24942", "SYSTEMD_NSS_BYPASS_BUS=1", "DBUS_STARTER_ADDRESS=unix:path=/run/dbus/system_bus_socket,guid=1514dcc38e0d60fe80fc0bd85ecbbcd6", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin", "INVOCATION_ID=aa6f0e519c5944a48b82802b25a7928d", "LANG=en_US.UTF-8"]) = 0 <0.003668>
...
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
Expected results:
No message if this is a false positive, or a proper way of setting the NOFILE limit if this is necessary.
prlimit() can fail with EPERM for a few reasons, but this could be that dbus-daemon does not have the CAP_SYS_RESOURCE capability set, or that the fd limit hard limit is attempting to be raised above the limit in /proc/sys/fs/nr_open, or some other manifestation of the calling process not being able to set the limits. Can you confirm that dbus-daemon has CAP_SYS_RESOURCE? Can you also confirm that this problem also occurs when running a regular (non-root user) dbus session bus?
FYI, running the following commands made the log message go away for me:
sed -e 's/.*DefaultLimitNOFILE=.*/DefaultLimitNOFILE=4096/g' /etc/systemd/system.conf
reboot
The solution might be overkill, but I'll leave it to someone else to refine it. I usually increase the open file limit anyway, so it works for me.
Oops, the correct sed command is "sed -i 's/.*DefaultLimitNOFILE=.*/DefaultLimitNOFILE=4096/g' /etc/systemd/system.conf' (replace "-e" with "-i")
The correct commands are:
sed -i 's/.*DefaultLimitNOFILE=.*/DefaultLimitNOFILE=4096/g' /etc/systemd/system.conf
reboot
After reading Jason's comment, I noticed that the LimitNOFILE systemd property for dbus seems to have change between 8.1 and 8.2.
$ grep ^VERSION= /etc/os-release
VERSION="8.1 (Ootpa)
systemctl show dbus --property=LimitNOFILE
LimitNOFILE=4096
grep ^VERSION= /etc/os-release
VERSION="8.2 (Ootpa)"
systemctl show dbus --property=LimitNOFILE
LimitNOFILE=262144
could it be related to this warning ?
If the defaults for the number of open files changed between 8.1 and 8.2, that could be the culprit, but the prlimit() call in comment #0 seems to have a valid soft and hard limit according to those default limits, and as I mentioned in comment #5, there are several reasons for a failure with a code of EPERM. As the new hard limit seems to be the same as the initial limit, it suggests that either the call is from an unprivileged process (which cannot raise the hard limit, so is presumably missing CAP_SYS_RESOURCE) or there is some other mechanism preventing the call.
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 (dbus 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-2021:4365
Description of problem: On RHEL 8.2 workstations, while logged in as root user, as soon as the root user executes a program that spawns a dbus service behind (e.g. "SELinux Troubleshooter"), the following message is seen in the journal, at Warning level: " Failed to reset fd limit before activating service: org.freedesktop.DBus.Error.AccessDenied: Failed to restore old fd limit: Operation not permitted " From DBus code, the message appears when DBus daemon's child tries to restore limits. This has no impact but is confusing to the users. dbus-1.12.8/bus/activation.c: -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< -------- 1711 static void 1712 child_setup (void *user_data) 1713 { 1714 #ifdef DBUS_UNIX 1715 BusActivation *activation = user_data; 1716 DBusRLimit *initial_fd_limit; 1717 DBusError error; 1718 1719 dbus_error_init (&error); 1720 initial_fd_limit = bus_context_get_initial_fd_limit (activation->context); 1721 1722 if (initial_fd_limit != NULL && 1723 !_dbus_rlimit_restore_fd_limit (initial_fd_limit, &error)) 1724 { 1725 /* unfortunately we don't actually know the service name here */ 1726 bus_context_log (activation->context, 1727 DBUS_SYSTEM_LOG_WARNING, 1728 "Failed to reset fd limit before activating " 1729 "service: %s: %s", 1730 error.name, error.message); 1731 } 1732 #endif 1733 } -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< -------- Version-Release number of selected component (if applicable): dbus-1.12.8-9.el8.x86_64 How reproducible: Always Steps to Reproduce: 1. Login as the root user in the GUI 2. Execute SELinux Troubleshooter (under Sundry folder) Actual results: Strace of dbus daemon shows: -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< -------- 3212 14:45:15.878851 prlimit64(0, RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=256*1024}, NULL) = -1 EPERM (Operation not permitted) <0.000020> 3212 14:45:15.879102 sendto(20<UNIX:[25770->6756]>, "<28>May 25 14:45:15 dbus-daemon[3212]: [system] Failed to reset fd limit before activating service: org.freedesktop.DBus.Error.AccessDenied: Failed to restore old fd limit: Operation not permitted", 196, MSG_NOSIGNAL, NULL, 0) = 196 <0.001304> 3212 14:45:15.880540 execve("//usr/libexec/dbus-1/dbus-daemon-launch-helper", ["//usr/libexec/dbus-1/dbus-daemon-launch-helper", "org.fedoraproject.Setroubleshootd"], ["DBUS_SYSTEM_BUS_ADDRESS=unix:path=/run/dbus/system_bus_socket,guid=1514dcc38e0d60fe80fc0bd85ecbbcd6", "DBUS_STARTER_BUS_TYPE=system", "JOURNAL_STREAM=9:24942", "SYSTEMD_NSS_BYPASS_BUS=1", "DBUS_STARTER_ADDRESS=unix:path=/run/dbus/system_bus_socket,guid=1514dcc38e0d60fe80fc0bd85ecbbcd6", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin", "INVOCATION_ID=aa6f0e519c5944a48b82802b25a7928d", "LANG=en_US.UTF-8"]) = 0 <0.003668> ... -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< -------- Expected results: No message if this is a false positive, or a proper way of setting the NOFILE limit if this is necessary.