Received: by 10.192.165.156 with SMTP id m28csp200692imm; Tue, 17 Apr 2018 08:44:03 -0700 (PDT) X-Google-Smtp-Source: AIpwx49DP5PCoA5jLgtq67nguzv9A9k1gEUkR0yZu4ILZ8io3dxCQT5toNyMODW18TuixLBRyv7g X-Received: by 10.98.36.76 with SMTP id r73mr2461267pfj.108.1523979843063; Tue, 17 Apr 2018 08:44:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523979843; cv=none; d=google.com; s=arc-20160816; b=dNsWT7twfT9P4uYt7TEuHkC9extVxM3r4Ae1uJyTCfX9nfHtBaiQrk3CkXOVnZndKR Ks69vBGxovWJ25Xf/l8nFS5zUJoWixuTdNQcTGfnHFEbIUjZqhYYmuUYDT0NHf5Ma/Ds HRq8y9rJv+Qe9hA4sLkQDH0v6vb8VN/zL2bhyMpQXEAoOQYY8fsI40SCaLbdY746TjiB EWF3drsQ3OiS5J+q2bvyV3bHAzJoan1258JNWzlaXll6ai/ePNKlt9FNr/T8QoSKya5e GjmNybWWKqM1GuVRwcQsB6g0HjZv16woCXuEd4A/lFsYuj9guXfi8PL2SWaSH6Mlejkh 9G1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature:arc-authentication-results; bh=fJqlleczz4B9zNkkAdm/pkq7Ez3V1gH2trxW9QoclVk=; b=MZPOCp8uqT9ACKjS71hWBX/myVnP71g24FgcXUxozKUcL1Uley241xnjJEsMPIrq4E W9kEFkTiBirk0U8nO8otv9LEnjSLJwMWewsXne39e7XJxSjkOva4Ho0nyzKS/dYjZKYZ vrzt9SzilMTprP6NNj+nb3HL3OZTMqTXs0RfISA5F1YoQYYiMT+XAixjJ9P9RfBu16ac L/kX5HZQuFaBr2uVEkcOgkEKGN3wtthHAeTfJjP005Ouvbjl9CM5Js1rwDVuEoht08p6 V/LUlvxNuhzqqvey6JOGfoWUpozWj7rijSCot74amAJk330thgf7C+aSGzpXzfBbWdS5 imPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@hansenpartnership.com header.s=20151216 header.b=tbtl0mUV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i4si5784618pgr.362.2018.04.17.08.43.48; Tue, 17 Apr 2018 08:44:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@hansenpartnership.com header.s=20151216 header.b=tbtl0mUV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752613AbeDQPmp (ORCPT + 99 others); Tue, 17 Apr 2018 11:42:45 -0400 Received: from bedivere.hansenpartnership.com ([66.63.167.143]:52906 "EHLO bedivere.hansenpartnership.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751187AbeDQPmo (ORCPT ); Tue, 17 Apr 2018 11:42:44 -0400 Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id 1CC8E8EE264; Tue, 17 Apr 2018 08:42:44 -0700 (PDT) Received: from bedivere.hansenpartnership.com ([127.0.0.1]) by localhost (bedivere.hansenpartnership.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PzZxJYMuM3m8; Tue, 17 Apr 2018 08:42:43 -0700 (PDT) Received: from [10.1.129.202] (unknown [141.170.9.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by bedivere.hansenpartnership.com (Postfix) with ESMTPSA id 963C58EE0E2; Tue, 17 Apr 2018 08:42:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=hansenpartnership.com; s=20151216; t=1523979763; bh=+omoRqWtCHbSzQQRhvKyMd/tgwAWayz8Wpu09SCTaQ8=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=tbtl0mUVTRoJeyviMxsIl0OgSn3Q/tRjoLgjeFuCi7Bn25IRWNosnZww0L0DDkz7x tZXVrbiNPn8LtF6tIqoZpbxGqzUl3wc4sU1gMik86a2rvuap2d8YdBf5bHOHe44rjI V/ls+mMXt9b2J0BfhdvoDWoYp5bbCKUW78HkUd88= Message-ID: <1523979759.3310.7.camel@HansenPartnership.com> Subject: Re: repeatable boot randomness inside KVM guest From: James Bottomley To: "Theodore Y. Ts'o" Cc: Matthew Wilcox , Alexey Dobriyan , linux-kernel@vger.kernel.org, linux-mm@kvack.org Date: Tue, 17 Apr 2018 16:42:39 +0100 In-Reply-To: <20180417151650.GA16738@thunk.org> References: <20180414195921.GA10437@avx2> <20180414224419.GA21830@thunk.org> <20180415004134.GB15294@bombadil.infradead.org> <1523956414.3250.5.camel@HansenPartnership.com> <20180417114728.GA21954@bombadil.infradead.org> <1523966232.3250.15.camel@HansenPartnership.com> <20180417151650.GA16738@thunk.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-04-17 at 11:16 -0400, Theodore Y. Ts'o wrote: > On Tue, Apr 17, 2018 at 12:57:12PM +0100, James Bottomley wrote: > > > > You don't have to compromise the bootloader to influence this, you > > merely have to trick it into providing the random number you > > wanted.  The bigger you make the attack surface (the more inputs) > > the more likelihood of finding a trick that works. > > There is a large class of devices where the bootloader can be > considered trusted.  For example, all modern Chrome and Android > devices have signed bootloaders by default.  And if you are using an > Amazon or Chrome VM, you are generally started it with a known, > trusted boot image. Depends how the parameter is passed. If it can be influenced from the command line then a large class of "trusted boot" systems actually don't verify the command line, so you can boot a trusted system and still inject bogus command line parameters. This is definitely true of PC class secure boot. Not saying it will always be so, just illustrating why you don't necessarily want to expand the attack surface. > The reason why it's useful to have the bootloader get the entropy is > because it may device-specific access and be able to leverage > whatever infrastructure was used to load the kernel and/or > intialramfs to also load the equivalent of /var/lib/systemd/random- > seed (or /var/lib/urandom, et. al) --- and do this early enough that > we can have truely secure randomness for those kernel faciliteis that > need access to real randomness to initialize the stack canary, or > initializing the slab cache. OK, in the UEFI ideal world where every component is a perfectly written OS, perhaps you're right. In the more real world, do you trust the people who wrote the bootloader to understand and correctly implement the cryptographically secure process of obtaining a random input? > There are other ways that this could be done, of course.  If the UEFI > boot services are still available, you might be able to ask the UEFI > services to give you randomness.  And yes, the hardware might be > backdoored to the fare-the-well by the MSS (for devices manufactured > in China) or by an NSA Tailored Access Operations intercepting a > computer shipment in transit.  But my vision was that this wouldn't > necessarily bump the entropy accounting or mark the CRNG as fully > intialized.  (If you work for the NSA and you're sure you won't do an > own-goal, you could enable a kernel boot option which marks the CRNG > initialized from entropy coming from UEFI or RDRAND or a TPM.  But I > don't think it should be the default.) > > The only goal was to get enough uncertainty so we can secure early > kernel users of entropy for security features such as kernel ASLR, > the kernel stack canary, SLAB freelist randomization, etc. > > And by the way --- if you think it is easy / possible to get secure > random numbers easily from either a TPMv1 or TPMv2 w/o any early boot > services (e.g., no interrupts, no DMA, no page tables, no memory > allocation) that would be really good to know. Well, as I said, I was planning to use the EFI driver (actually for IMA, but it works here too) which should be present to the kernel on boot. We also don't have quite the severe restrictions you say. The bootmem interface is usable for allocations (even ones that persist beyond init discard) and, although most TPMs are actually polled devices, it is possible to use interrupt drivers that do DMA via UEFI in early boot provided you know what you're doing. James