Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp3246234rdb; Tue, 6 Feb 2024 11:19:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IF9eaPz26s3BTsRH7xqLRvzBVmi0WsPp+6hwRI3fJM08PsS9/Xpw7E+pFani1+d/Kdy0t0q X-Received: by 2002:a05:6a00:170d:b0:6e0:47b9:b727 with SMTP id h13-20020a056a00170d00b006e047b9b727mr645682pfc.30.1707247167578; Tue, 06 Feb 2024 11:19:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707247167; cv=pass; d=google.com; s=arc-20160816; b=gS+Sdo59n5hqNf6GnqAp28YMfYoXWaR7ZOz+pXl8Xic4FWQDYl1jympRsLhIBcN3As do+LCvBaaeJdySLDvCVhSa4v2gYbWMSNhN8Jo+XHH9ZBFU1d1JV45gFPv5zwL6HVkDyR EffqqME6jxLi+RQ6G0/heutYj1FzAWe7N02PVeS6P6h6ZPh8vKagMSP4PWtB7PAIHQ+o +fsYTCC2WYfFUh/kAMwiw+PnyVhQmMlX/9x4zJ90xEbYrTEqzLM/Ydr+/Ze3VsNqW5cH d6hLkf3Q3WVrfehYKOb9eGsGIK6NQpJISUutCkfupHbSXGIEYgJbbnSEEecwBP7jTG30 Ddpg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:references:in-reply-to :user-agent:subject:cc:to:from:date:dkim-signature:dkim-filter; bh=/E4fg2gasMcWdntZWwFj38PVFbI5P1u58WKFuSARsxc=; fh=/mNWIH353cBlFvLInNWcyB9dS1cCKwL+egFjrDvS2F8=; b=VjXLNKsZfQ50AB3DOY7fQNh+L8gidimpfVNXMZjaWomlVOfNdl6wp4NcZBOBmzA6E5 utqAnBnRboJMxR+LpvyxdXeXp4HyDY1a5t/jqAQNlzcA1QCkCU2V4mYqcZnPGnRhQfQR AFtJCTKD6VZY9+/fLDVPePOI8HtHZJlHV8JTRw/Kt3UnBaXTyGgeNifsnx6QTbUyAxWg 5YSUI+2PPIPWO+eYWSFJjXeJET25OjvVljKgCgoD2PMZYdF5vE4JYdSkmgVzraC6USA4 AhIGBLPxQK7Gt4876WZpbtRwvTk9DgmALiTtPa6rCwUXf/tNhIVS9JqFwQadEt707lto zcyQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@zytor.com header.s=2024011201 header.b=uMLtbKsy; arc=pass (i=1 spf=pass spfdomain=zytor.com dmarc=pass fromdomain=zytor.com); spf=pass (google.com: domain of linux-kernel+bounces-55545-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55545-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zytor.com X-Forwarded-Encrypted: i=1; AJvYcCW2yHVf5u2u4pI0WBMPe9NQiQHRN1U7GjCJJHIHm0Wp6anWGVWQ228lJH2zZmvOYO4sqkRcAsHKfd0gGtAEGMzYTshU++OFVfj6PT/p6Q== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d16-20020a056a00199000b006e04bccfdefsi2091818pfl.138.2024.02.06.11.19.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 11:19:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55545-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=fail header.i=@zytor.com header.s=2024011201 header.b=uMLtbKsy; arc=pass (i=1 spf=pass spfdomain=zytor.com dmarc=pass fromdomain=zytor.com); spf=pass (google.com: domain of linux-kernel+bounces-55545-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55545-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C1222B213A7 for ; Tue, 6 Feb 2024 19:12:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4C73713FF8; Tue, 6 Feb 2024 19:12:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b="uMLtbKsy" Received: from mail.zytor.com (terminus.zytor.com [198.137.202.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC6A013FF2 for ; Tue, 6 Feb 2024 19:12:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.136 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707246770; cv=none; b=tPaueWTjelzx88x9hOAzbIMjfQEAJi9HPz2xGHXJDmpd/orzBUQKKBxqyNJutp1MIT3zRXPOW87k4LpAzbt9dCvofwVrHFsUQSDH4s+iNi37z13YxRFE6gBkGoUncbBouiK3jsTw/3BXsmr9qrrm0pUF9iEW/SYE8NnKAY1HlQ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707246770; c=relaxed/simple; bh=QIX8ThrxEN/63pZ8mRtmW7NV4oz3tc5pqgfER4WuGZQ=; h=Date:From:To:CC:Subject:In-Reply-To:References:Message-ID: MIME-Version:Content-Type; b=q+G3z7XKRa5PVpTXLhyTgGbdInK+d1CzIGWnCzQxUTIebEgrk0aqEFTX7kW78bu+oxcl4NlPhYrxjNYHDatkFWF9A85tWBHIdnI2imnxvbHpXoQhz/HYcJUxpNVE/NRlS23eXA7fV/efZ430C+o7XwI6+2FIUOqUlzTZHzF4vCg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zytor.com; spf=pass smtp.mailfrom=zytor.com; dkim=fail (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b=uMLtbKsy reason="signature verification failed"; arc=none smtp.client-ip=198.137.202.136 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zytor.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zytor.com Received: from [127.0.0.1] ([76.133.66.138]) (authenticated bits=0) by mail.zytor.com (8.17.2/8.17.1) with ESMTPSA id 416JCCeF2336557 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Tue, 6 Feb 2024 11:12:13 -0800 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 416JCCeF2336557 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2024011201; t=1707246734; bh=/E4fg2gasMcWdntZWwFj38PVFbI5P1u58WKFuSARsxc=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=uMLtbKsyKS5HG8bI9WVODWUgmtAbiisxY67Yk4/FwkgGt+guW5fPDfogSOkaWZPdV mO8RJ/gvv+KsrSqcFDHrr6MNNzeEctYsgXWVau6wxabhW0wACq9ayptzrXc38hZ6rF jCD5yek3PtSCuphTvbLGl3jTPS25dTCmfK7ZdjXIlVz/Fl/A/r5UC6J622JhfCUQk9 AJPUv/BEyjDW3875YK+cNaE2FA88o9nN6XnxdeMNgzfIF5UCZ2uAm/p0lH/LEi/Pfn NlGwfIWTu6WtLSOn/gZNHfwePXvRvNyY7Rj5cJLIoSq/L1Ir296X1LuK7cpP2foBbN CkfBas0vb80dQ== Date: Tue, 06 Feb 2024 11:12:08 -0800 From: "H. Peter Anvin" To: "Theodore Ts'o" , James Bottomley CC: "Jason A. Donenfeld" , "Reshetova, Elena" , Dave Hansen , "Kirill A. Shutemov" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "x86@kernel.org" , Kuppuswamy Sathyanarayanan , "Nakajima, Jun" , Tom Lendacky , "Kalra, Ashish" , Sean Christopherson , "linux-coco@lists.linux.dev" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 1/2] x86/random: Retry on RDSEED failure User-Agent: K-9 Mail for Android In-Reply-To: <20240203143547.GC36616@mit.edu> References: <20240131140756.GB2356784@mit.edu> <20240131171042.GA2371371@mit.edu> <20240201045710.GD2356784@mit.edu> <20240202160515.GC119530@mit.edu> <6ccd8c7998542f1ac68514700fb9e31049a3a3c7.camel@linux.ibm.com> <20240203143547.GC36616@mit.edu> Message-ID: <60465F66-46A6-4A16-97AC-38EAE3FC67DA@zytor.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On February 3, 2024 6:35:47 AM PST, Theodore Ts'o wrote: >On Fri, Feb 02, 2024 at 10:28:01PM +0100, James Bottomley wrote: >>=20 >> My big concern is older cpus where rdrand/rdseed don't produce useful >> entropy=2E Exhaustion attacks are going to be largely against VMs not >> physical systems, so I worry about physical systems with older CPUs >> that might have rdrand issues which then trip our Confidential >> Computing checks=2E > >For (non-CC) VM's the answer is virtio-rng=2E This solves the >exhaustion problem, since if you can't trust the host, the VM's >security is taost anyway (again, ignoring Confidential Compute)=2E > >> The signal for rdseed failing is fairly clear, so if the node has other >> entropy sources, it should continue otherwise it should signal failure= =2E >> Figuring out how a confidential computing environment signals that >> failure is TBD=2E > >That's a design decision, and I believe we've been converging on a >panic during early boot=2E Post boot, if we've successfully succeeded >in initializing the guest kernel's RNG, we're secure so long as the >cryptographic primitives haven't been defeated --- and if we have, >such as if Quantuum Computing because practical, we've got bigger >problems anyway=2E > > - Ted I also want to emphasize that there is a huge difference between boot (ini= tialization) time and runtime=2E Runtime harvesting has always been opportu= nistic in Linux, and so if RDSEED fails, try again later =E2=80=93 unless p= erhaps a task is blocked on /dev/random in which case it might make sense t= o aggressively loop on the blocked core instead of just putting the process= to sleep=2E Initialization time is a different game entirely=2E Until we have accumula= ted about 256-512 bits of seed data, even the best PRNG can't really be con= sidered "completely random=2E" Thus a far more aggressive approach may be c= alled for; furthermore, this is the time to look for total failure of the N= RBG if after some number N attempts (where I believe N should be quite larg= e, if we spend a full second in the very worst case that is probably better= than declaring failure and optionally panic the system) we have not acquir= ed enough entropy then warn and optionally panic the system=2E By setting the limit in terms of time rather than iterations, this avoids = the awkward issue of "the interface to the RDSEED unit is too fast and so i= t returns failure too often=2E" I don't think anyone would argue that the r= ight thing would be to slow down the response time of RDSEED for that reaso= n, even though it would most likely radically reduce the failure rate (beca= use the NRBG would have more time to produce entropy between queries at the= maximum rate=2E) Let's say, entirely hypothetically (as of right now I have absolutely *no*= insider information of the RNG unit roadmap), that we were to implement a = prefetch buffer in the core, such that a single or a handful of RD* instruc= tions could execute in a handful of cycles, with the core itself issuing th= e request to the RNG unit when there is space in the queue=2E Such a prefet= ch buffer could rather obviously get *very* quickly exhausted because the p= oll rate could be dramatically increased, and having the core stall until t= here is data may or may not be a good solution (advantage: the CPU can go t= o a lower power state while waiting; disadvantage: opportunistic harvesting= would prefer a "poll and fail fast" variation, *especially* if the CPU is = going to fulfill the request autonomously anyway=2E)