From nobody Sat Feb 7 03:54:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=eu.citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1589915016; cv=none; d=zohomail.com; s=zohoarc; b=eLtX7JeyU29Wa1jg9TYyGmxTHtQwDXhU4Ejy67klyJtjK8JQ8flrkimva/fDTp6eYgy4rfbrO/awyvNMDQoCg8BU3kjmOZt955QamdEF2RivZVhBC+EYZOovWJE1kWYmrenXGs7rZq6ObX80ChMkSh1hRhqwH+CDXfo6LIarJcY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589915016; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3zfVTFHzS9r2yH5zg2LJ/gfrgASxbXs+Yf3miM5aq3w=; b=hzOdd/+DHAAPf5rGmGIxKbVPig9C5mHvWGRRw+z+53ReMpYG8ilxlst6A0ybCGvn//0WGqA0zxtq9Ev8brqeYpwL3pcWjmFPwv6WHv833ou5w+wGPTZJvvXBs6QTCXTbHP3CCbHOgVZla3BkoGCbtcV3bb+A0yXaQAkkaB5GBDk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1589915016102266.3992393545594; Tue, 19 May 2020 12:03:36 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jb7WM-0004rz-Gz; Tue, 19 May 2020 19:03:22 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jb7WL-0004rB-7l for xen-devel@lists.xenproject.org; Tue, 19 May 2020 19:03:21 +0000 Received: from chiark.greenend.org.uk (unknown [2001:ba8:1e3::3]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4de532a2-9a03-11ea-9887-bc764e2007e4; Tue, 19 May 2020 19:02:37 +0000 (UTC) Received: from [172.18.45.5] (helo=zealot.relativity.greenend.org.uk) by chiark.greenend.org.uk (Debian Exim 4.84_2 #1) with esmtp (return-path ijackson@chiark.greenend.org.uk) id 1jb7Vc-0001da-Lt; Tue, 19 May 2020 20:02:36 +0100 X-Inumbo-ID: 4de532a2-9a03-11ea-9887-bc764e2007e4 From: Ian Jackson To: xen-devel@lists.xenproject.org Subject: [OSSTEST PATCH 09/38] Bodge systemd random seed arrangements Date: Tue, 19 May 2020 20:02:01 +0100 Message-Id: <20200519190230.29519-10-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519190230.29519-1-ian.jackson@eu.citrix.com> References: <20200519190230.29519-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Content-Type: text/plain; charset="utf-8" systemd does not regard the contents of the random seed file as useful for the purposes of placating the kernel's entropy tracker. As a result, the system hangs at boot waiting for entropy. Fix this by providing a small program which can be used to load a seed file into /dev/random and also call RNDADDTOENTCNT to add the appropriate amount to the kernel's counter. Arrange to run this program instead of /lib/systemd/systemd-random-seed load With systemd the random seed file is in /var/lib/systemd/random-seed rather than /var/lib/urandom/random-seed. Unfortunately we must hardcode the actual numerical value of RNDADDTOENTCNT because we don't have a suitable compiler anywhere nearby. It seems to have the same value on i386, amd64, armhf and arm64, our currently supported architectures. Thanks to Colin Watson for pointers to the systemd random unit and Matthew Vernon for instructions on overriding just ExecStart. I think this change should be a no-op on non-systemd systems. Signed-off-by: Ian Jackson --- .../override.conf | 3 ++ overlay/usr/local/bin/random-seed-add | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 overlay/etc/systemd/system/systemd-random-seed.service.= d/override.conf create mode 100755 overlay/usr/local/bin/random-seed-add diff --git a/overlay/etc/systemd/system/systemd-random-seed.service.d/overr= ide.conf b/overlay/etc/systemd/system/systemd-random-seed.service.d/overrid= e.conf new file mode 100644 index 00000000..f6cc0f84 --- /dev/null +++ b/overlay/etc/systemd/system/systemd-random-seed.service.d/override.conf @@ -0,0 +1,3 @@ +[Service] +ExecStart=3D +ExecStart=3D/usr/local/bin/random-seed-add /var/lib/systemd/random-seed diff --git a/overlay/usr/local/bin/random-seed-add b/overlay/usr/local/bin/= random-seed-add new file mode 100755 index 00000000..89e75c4d --- /dev/null +++ b/overlay/usr/local/bin/random-seed-add @@ -0,0 +1,33 @@ +#!/usr/bin/perl -w +use strict; + +open R, '>', '/dev/random' or die "open /dev/random: $!\n"; +R->autoflush(1); + +sub rndaddtoentcnt ($) { + my ($bits) =3D @_; + my $x =3D pack 'L', $bits; + my $r =3D ioctl R, 0x40045201, $x; + defined $r or die "RNDADDTOENTCNT: $!\n"; +} + +sub process_stdin ($) { + my ($f) =3D @_; + my $got =3D read STDIN, $_, 512; + defined $got or die "read $f: $!\n"; + last if !$got; + print R $_ or die "write /dev/random: $!\n"; + my $bits =3D length($_) * 8; + rndaddtoentcnt($bits); +} + +if (!@ARGV) { + process_stdin('stdin'); +} else { + die "no options supported\n" if $ARGV[0] =3D~ m/^\-/; + foreach my $f (@ARGV) { + open STDIN, '<', $f or die "open for reading $f: $!\n"; + process_stdin($f); + } +} + --=20 2.20.1