Control: reassign -1 binfmt-support
Control: tags -1 + patch

Am 02.06.22 um 11:16 schrieb Michael Biebl:
Am 01.06.22 um 13:18 schrieb Colin Watson:
On Wed, Jun 01, 2022 at 11:25:21AM +0200, Michael Biebl wrote:
what you see here is a race condition between binfmt-support.service and
systemd-binfmt.service.
E.g. qemu installs binfmt config files for both binfmt-support and
systemd-binfmt leading to the issue you see.

I plan to add a
ConditionFileIsExecutable=!/usr/sbin/update-binfmts
to systemd-binfmt.service. This will disable systemd-binfmt.service when
binfmt-support is installed and should mitigate this issue.
(thus reassigning to systemd)

Thanks for investigating that.

Thinking more about it, it might actually be preferrable, if this condition is shipped by binfmt-support via a drop-in config for systemd-binfmt.service.

Thinking about this a bit more, binfmt.d might not strictly be a subset of the config files shipped for binfmt-support. So disabling systemd-binfmt.service via a Condition might not be the best way forward.

Since we only need to ensure, that systemd-binfmt.service and binfmt-support.service do not run concurrently (and both trying to access /proc/sys/fs/binfmt_misc/register), we simply need to apply a proper ordering. Thankfully, this is rather simple and the attached patch is even more minimal then the previous one. I chose to run binfmt-support.service after systemd-binfmt.service, as the former is pulled in via multi-user.target and the latter via sysinit.target.

Regards,
Michael
From 88ede367c9534481ac97faef6392000dc974e334 Mon Sep 17 00:00:00 2001
From: Michael Biebl <[email protected]>
Date: Thu, 2 Jun 2022 12:56:11 +0200
Subject: [PATCH] Run binfmt-support.service after systemd-binfmt.service

This fixes a race condition during boot when both services try to access
/proc/sys/fs/binfmt_misc/register at the same time which can lead to the
following error:

 systemd[1]: Starting Enable support for additional executable binary formats...
 update-binfmts[536]: update-binfmts: warning: unable to close /proc/sys/fs/binfmt_misc/register: File exists
 update-binfmts[536]: update-binfmts: warning: unable to close /proc/sys/fs/binfmt_misc/register: File exists
 update-binfmts[536]: update-binfmts: warning: unable to close /proc/sys/fs/binfmt_misc/register: File exists
 update-binfmts[536]: update-binfmts: exiting due to previous errors
 systemd[1]: binfmt-support.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
 systemd[1]: binfmt-support.service: Failed with result 'exit-code'.
 systemd[1]: Failed to start Enable support for additional executable binary formats.

Fixes Debian bug #1012154.
---
 init/systemd/binfmt-support.service.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/init/systemd/binfmt-support.service.in b/init/systemd/binfmt-support.service.in
index 25c30e2..f6d0d4d 100644
--- a/init/systemd/binfmt-support.service.in
+++ b/init/systemd/binfmt-support.service.in
@@ -20,7 +20,7 @@
 Description=Enable support for additional executable binary formats
 Documentation=man:update-binfmts(8)
 DefaultDependencies=false
-After=local-fs.target proc-sys-fs-binfmt_misc.automount
+After=local-fs.target proc-sys-fs-binfmt_misc.automount systemd-binfmt.service
 
 [Service]
 Type=oneshot
-- 
2.36.1

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to