From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 9F78715808D for ; Fri, 22 Apr 2022 23:54:37 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7B45EE0802; Fri, 22 Apr 2022 23:54:36 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 5D82FE0802 for ; Fri, 22 Apr 2022 23:54:35 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 946503419A2 for ; Fri, 22 Apr 2022 23:54:33 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id CFC982D7 for ; Fri, 22 Apr 2022 23:54:31 +0000 (UTC) From: "Mike Gilbert" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Gilbert" Message-ID: <1650671654.7c17fe616d1b710aa29c84bcc32c3f22417fb201.floppym@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: sys-apps/dbus/files/, sys-apps/dbus/ X-VCS-Repository: repo/gentoo X-VCS-Files: sys-apps/dbus/dbus-1.12.22-r1.ebuild sys-apps/dbus/dbus-1.12.22.ebuild sys-apps/dbus/dbus-1.14.0-r1.ebuild sys-apps/dbus/dbus-1.14.0.ebuild sys-apps/dbus/files/dbus-1.14.0-oom_score_adj.patch X-VCS-Directories: sys-apps/dbus/ sys-apps/dbus/files/ X-VCS-Committer: floppym X-VCS-Committer-Name: Mike Gilbert X-VCS-Revision: 7c17fe616d1b710aa29c84bcc32c3f22417fb201 X-VCS-Branch: master Date: Fri, 22 Apr 2022 23:54:31 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: c297682e-8ccb-4686-a970-a78f0364cc14 X-Archives-Hash: 0bff669ec4f52d57cbca4eedb62a4c6f commit: 7c17fe616d1b710aa29c84bcc32c3f22417fb201 Author: Mike Gilbert gentoo org> AuthorDate: Fri Apr 22 23:51:44 2022 +0000 Commit: Mike Gilbert gentoo org> CommitDate: Fri Apr 22 23:54:14 2022 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7c17fe61 sys-apps/dbus: do not open /proc/self/oom_score_adj for writing Bug: https://bugs.gentoo.org/836560 Closes: https://bugs.gentoo.org/839795 Bug: https://bugs.gentoo.org/839807 Closes: https://bugs.gentoo.org/839834 Closes: https://bugs.gentoo.org/839837 Closes: https://bugs.gentoo.org/840119 Closes: https://bugs.gentoo.org/840125 Closes: https://bugs.gentoo.org/840161 Signed-off-by: Mike Gilbert gentoo.org> ...{dbus-1.12.22.ebuild => dbus-1.12.22-r1.ebuild} | 6 +- .../{dbus-1.14.0.ebuild => dbus-1.14.0-r1.ebuild} | 6 +- .../dbus/files/dbus-1.14.0-oom_score_adj.patch | 115 +++++++++++++++++++++ 3 files changed, 121 insertions(+), 6 deletions(-) diff --git a/sys-apps/dbus/dbus-1.12.22.ebuild b/sys-apps/dbus/dbus-1.12.22-r1.ebuild similarity index 99% rename from sys-apps/dbus/dbus-1.12.22.ebuild rename to sys-apps/dbus/dbus-1.12.22-r1.ebuild index 0491fc1085d8..6490a2e922d7 100644 --- a/sys-apps/dbus/dbus-1.12.22.ebuild +++ b/sys-apps/dbus/dbus-1.12.22-r1.ebuild @@ -64,6 +64,9 @@ PATCHES=( "${FILESDIR}/dbus-daemon-optional.patch" # bug #653136 "${FILESDIR}/dbus-1.12.22-check-fd.patch" + + # https://bugs.gentoo.org/836560 + "${FILESDIR}/dbus-1.14.0-oom_score_adj.patch" ) pkg_setup() { @@ -207,9 +210,6 @@ multilib_src_compile() { } src_test() { - # https://bugs.gentoo.org/836560 - addwrite /proc/self - DBUS_VERBOSE=1 virtx emake -j1 -C "${TBD}" check } diff --git a/sys-apps/dbus/dbus-1.14.0.ebuild b/sys-apps/dbus/dbus-1.14.0-r1.ebuild similarity index 99% rename from sys-apps/dbus/dbus-1.14.0.ebuild rename to sys-apps/dbus/dbus-1.14.0-r1.ebuild index 2cddb00c4761..ce9df1f58e2e 100644 --- a/sys-apps/dbus/dbus-1.14.0.ebuild +++ b/sys-apps/dbus/dbus-1.14.0-r1.ebuild @@ -68,6 +68,9 @@ PATCHES=( "${FILESDIR}/dbus-1.14.0-x-autoconf-fixes.patch" "${FILESDIR}/dbus-1.12.22-check-fd.patch" + + # https://bugs.gentoo.org/836560 + "${FILESDIR}/dbus-1.14.0-oom_score_adj.patch" ) pkg_setup() { @@ -207,9 +210,6 @@ multilib_src_compile() { } src_test() { - # https://bugs.gentoo.org/836560 - addwrite /proc - # DBUS_TEST_MALLOC_FAILURES=0 to avoid huge test logs # https://gitlab.freedesktop.org/dbus/dbus/-/blob/master/CONTRIBUTING.md#L231 DBUS_TEST_MALLOC_FAILURES=0 DBUS_VERBOSE=1 virtx emake -j1 -C "${TBD}" check diff --git a/sys-apps/dbus/files/dbus-1.14.0-oom_score_adj.patch b/sys-apps/dbus/files/dbus-1.14.0-oom_score_adj.patch new file mode 100644 index 000000000000..094529708088 --- /dev/null +++ b/sys-apps/dbus/files/dbus-1.14.0-oom_score_adj.patch @@ -0,0 +1,115 @@ +From 499cdfde1b3f5d812912e89b1a1a0d7a4fb83306 Mon Sep 17 00:00:00 2001 +From: Simon McVittie +Date: Fri, 1 Apr 2022 18:58:34 +0100 +Subject: [PATCH 1/2] activation-helper: Never crash if unable to write + oom_score_adj + +_dbus_warn() normally only logs a warning, but can be made fatal by +environment variables. In particular, we do that during unit testing, +which can result in a build-time test failure if dbus is built in a +sandbox environment that prevents write access. + +_dbus_log() does only the logging part of _dbus_warn(), which seems +more appropriate here. + +Signed-off-by: Simon McVittie +--- + bus/activation-helper.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/bus/activation-helper.c b/bus/activation-helper.c +index 8a4fd732..df0472ce 100644 +--- a/bus/activation-helper.c ++++ b/bus/activation-helper.c +@@ -348,7 +348,7 @@ exec_for_correct_user (char *exec, char *user, DBusError *error) + /* Resetting the OOM score adjustment is best-effort, so we don't + * treat a failure to do so as fatal. */ + if (!_dbus_reset_oom_score_adj (&error_str)) +- _dbus_warn ("%s: %s", error_str, strerror (errno)); ++ _dbus_log (DBUS_SYSTEM_LOG_WARNING, "%s: %s", error_str, strerror (errno)); + + if (!switch_user (user, error)) + return FALSE; +-- +GitLab + + +From 5c8e5b7140c4f1f88684c7a83ce9587fff2def0c Mon Sep 17 00:00:00 2001 +From: Simon McVittie +Date: Fri, 1 Apr 2022 18:56:26 +0100 +Subject: [PATCH 2/2] sysdeps: Only open oom_score_adj read/write if we need to + write it + +If we're running in a sandbox, we might not have write access to +oom_score_adj. In the common case where we don't have any special +protection from the OOM-killer, we can detect that with only read +access, and skip the part where we open it for writing. + +(We would also not have write access to oom_score_adj if we're running +with elevated Linux capabilities while not root, but that should never +actually happen for dbus-daemon-launch-helper, which is setuid root +for production use or has no capabilities during unit-testing.) + +Signed-off-by: Simon McVittie +--- + dbus/dbus-sysdeps-util-unix.c | 26 +++++++++++++++++++++++--- + 1 file changed, 23 insertions(+), 3 deletions(-) + +diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c +index 8f079cbf..ca130cff 100644 +--- a/dbus/dbus-sysdeps-util-unix.c ++++ b/dbus/dbus-sysdeps-util-unix.c +@@ -1627,12 +1627,12 @@ _dbus_reset_oom_score_adj (const char **error_str_p) + const char *error_str = NULL; + + #ifdef O_CLOEXEC +- fd = open ("/proc/self/oom_score_adj", O_RDWR | O_CLOEXEC); ++ fd = open ("/proc/self/oom_score_adj", O_RDONLY | O_CLOEXEC); + #endif + + if (fd < 0) + { +- fd = open ("/proc/self/oom_score_adj", O_RDWR); ++ fd = open ("/proc/self/oom_score_adj", O_RDONLY); + if (fd >= 0) + _dbus_fd_set_close_on_exec (fd); + } +@@ -1680,6 +1680,26 @@ _dbus_reset_oom_score_adj (const char **error_str_p) + goto out; + } + ++ close (fd); ++#ifdef O_CLOEXEC ++ fd = open ("/proc/self/oom_score_adj", O_WRONLY | O_CLOEXEC); ++ ++ if (fd < 0) ++#endif ++ { ++ fd = open ("/proc/self/oom_score_adj", O_WRONLY); ++ if (fd >= 0) ++ _dbus_fd_set_close_on_exec (fd); ++ } ++ ++ if (fd < 0) ++ { ++ ret = FALSE; ++ error_str = "open(/proc/self/oom_score_adj) for writing"; ++ saved_errno = errno; ++ goto out; ++ } ++ + if (pwrite (fd, "0", sizeof (char), 0) < 0) + { + ret = FALSE; +@@ -1700,7 +1720,7 @@ _dbus_reset_oom_score_adj (const char **error_str_p) + else + { + ret = FALSE; +- error_str = "open(/proc/self/oom_score_adj)"; ++ error_str = "open(/proc/self/oom_score_adj) for reading"; + saved_errno = errno; + goto out; + } +-- +GitLab +