Received: by 10.192.165.156 with SMTP id m28csp98174imm; Tue, 17 Apr 2018 07:09:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx49WhD0+ZFsRbYBxMMYGUNnYqFdhLXzvHYjczNTViRoKv7ErIRYELGhF1ssBh9a9CsqL8BPE X-Received: by 10.101.78.205 with SMTP id w13mr1881197pgq.83.1523974149954; Tue, 17 Apr 2018 07:09:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523974149; cv=none; d=google.com; s=arc-20160816; b=Y6C7bcOGg3OHbCDCjk5VNxUdZykM7+Tzpj619pr5kg1dmJlDJBUFqtDOiEograe/64 bbkpoE3rRYAj17aUHTSVUp0cBkCOe6ngECOW7X0QC922HqzTZ0x4Y/qGpFTuDeER/5XY 6L3S8Cbn5vkfSq7X0VmFKrnyOXc8+JFiX7tD9IxxzoY9NNWAEbvYVhoEfqhA+0j7bEcU XY3RRofF3Zr/i/Ug/G5wiFr6qt0ViNlpX8pckMMa0xuS7/xjkCtFmfc6Rwg8moaOFzUj 8rVRDXmLALYSR7+TQxvaiOUJ2H/BcvsUZP4ib5VfYq8IXO8zCDcsyJMpXeEve0Usu03t rv8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=japXjecRabM9HLc0YuNCee2UP8gMNUWw4u4YocQDlMk=; b=sRnUSun/MTgIAkKLSUBsLL22PY4v2VJLWVvwp36EoXvemtZPDfP48N2IeexSgInKu7 d94H1keZehzu37vfPUeLu+uEG3GKwhsML4Xa2rNRwbmkOPZF6RFW2fmZrMgnHOD2XDu3 llO4NbStrZ7tdK4+KVB71qCvNzB2hTbP8wWqQzJnEXAteu2wxTqbmVfKyvU+RKe4oUBF CwxXX73KavPyGLepbBuNSRApAahSIWBARgfz0qka4OYUJ3aPPZa+iBczxR+B24WkZKYG KfXvHq+ba3YHwT+VOxtrQsBBLXbFN6WEfCwXARNS11rwXzEKtEkMYthonyuS+tECX+UN 2sjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=PK1bJ1FP; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c18si12896981pfe.36.2018.04.17.07.08.55; Tue, 17 Apr 2018 07:09:09 -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=@infradead.org header.s=bombadil.20170209 header.b=PK1bJ1FP; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752883AbeDQOH0 (ORCPT + 99 others); Tue, 17 Apr 2018 10:07:26 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:33472 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751865AbeDQOHX (ORCPT ); Tue, 17 Apr 2018 10:07:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=japXjecRabM9HLc0YuNCee2UP8gMNUWw4u4YocQDlMk=; b=PK1bJ1FPP1smxwm0qoq+OlwtvA 6nZKHedmBrxVCG+iI6kCt8a1g5do+DNl8Ct9SyZMDQA97eCq1PAQrY7/VrlHfbxAchUzuLM3KESC4 xb0am6g08tSVCYZrSgMsRmaNLRAx41RudZUl4V+pkhfqS3TgAAaw3dJleYxRLRNFpRYzL/CVHk6WZ R/tWjczNte1JCHhS51eXgeQMO9PNf9R3dHdibc4QZdO/FIA+WHcHigKAytaALfzXIyae1X/YGqqOs VII2gC/WidX/HdACBV+7sm9vG9GztPYUHzIvcI0LLAvJZFc0x91NTDjLDC2l4bl3wTUFIIgRYvgae vC17nKvg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1f8RGU-0003k0-Un; Tue, 17 Apr 2018 14:07:22 +0000 Date: Tue, 17 Apr 2018 07:07:22 -0700 From: Matthew Wilcox To: James Bottomley Cc: "Theodore Y. Ts'o" , Alexey Dobriyan , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: repeatable boot randomness inside KVM guest Message-ID: <20180417140722.GC21954@bombadil.infradead.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> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1523966232.3250.15.camel@HansenPartnership.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 17, 2018 at 12:57:12PM +0100, James Bottomley wrote: > On Tue, 2018-04-17 at 04:47 -0700, Matthew Wilcox wrote: > > On Tue, Apr 17, 2018 at 10:13:34AM +0100, James Bottomley wrote: > > > On Sat, 2018-04-14 at 17:41 -0700, Matthew Wilcox wrote: > > > > On Sat, Apr 14, 2018 at 06:44:19PM -0400, Theodore Y. Ts'o wrote: > > > > > What needs to happen is freelist should get randomized much > > > > > later in the boot sequence.??Doing it later will require > > > > > locking; I don't know enough about the slab/slub code to know > > > > > whether the slab_mutex would be sufficient, or some other lock > > > > > might need to be added. > > > > > > > > Could we have the bootloader pass in some initial randomness? > > > > > > Where would the bootloader get it from (securely) that the kernel > > > can't? > > > > In this particular case, qemu is booting the kernel, so it can apply > > to /dev/random for some entropy. > > Well, yes, but wouldn't qemu virtualize /dev/random anyway so the guest > kernel can get it from the HWRNG provided by qemu? The part of Ted's mail that I snipped explained that virtio-rng relies on being able to kmalloc memory, so by definition it can't provide entropy before kmalloc is initialised. > > I thought our model was that if somebody had compromised the > > bootloader, all bets were off. > > 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. > > > ??And also that we were free to mix in as many untrustworthy bytes of > > alleged entropy into the random pool as we liked. > > No, entropy mixing ensures that all you do with bad entropy is degrade > the quality, but if the quality degrades to zero (as it might at boot > when you've no other entropy sources so you feed in 100% bad entropy), > then the random sequences become predictable. I don't understand that. If I estimate that I have 'k' bytes of entropy in my pool, and then I mix in 'n' entirely predictable bytes, I should still have k bytes of entropy in the pool. If I withdraw k bytes from the pool, then yes the future output from the pool may be entirely predictable, but I have to know what those k bytes were.