From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936227AbcJVDno (ORCPT ); Fri, 21 Oct 2016 23:43:44 -0400 Received: from mail.eperm.de ([89.247.134.16]:46204 "EHLO mail.eperm.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932754AbcJVDnn (ORCPT ); Fri, 21 Oct 2016 23:43:43 -0400 From: Stephan Mueller To: Ted Tso Cc: linux-kernel@vger.kernel.org Subject: why getrandom blocking does not work with /dev/urandom Date: Sat, 22 Oct 2016 05:43:36 +0200 Message-ID: <13074229.arz8HkBRPc@positron.chronox.de> User-Agent: KMail/5.3.1 (Linux/4.7.7-200.fc24.x86_64; KDE/5.26.0; x86_64; ; ) MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ted, as mentioned, I looked a bit deeper into the issue of adding the blocking behavior of getrandom to /dev/urandom. As you and I already identified, moving that blocking behavior to /dev/urandom simply does not work. The system does not boot. The reason to this issue is actually quite simple. The init process of systemd reads /dev/urandom for whatever purpose. Now, when /dev/urandom blocks during boot, systemd will be blocked too. That means that user space (either in the initramfs or with the regular root partition) is set up. When there is no user space initialized, there are no devices set up. The network card is not initialized, the block devices are not mounted, other devices are not initialized. That means that neither interrupts nor block device events are registered. The only device that does not need setup and that will generate events is a keyboard / mouse whose drivers are statically compiled (or other devices that trigger interrupts without requiring any user space setup procedure). Thus, if you use HID long enough, the kernel will eventually receive sufficient entropy from these events, release systemd and user space starts. However, just by itself, user space will almost never start with a blocking behavior of /dev/urandom. Ciao Stephan