Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2446754rdb; Wed, 21 Feb 2024 07:59:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWFjUDTSwgMKwWDi+d+/48V4rc26l7Y8kBRo8dxB4OWxCWQa8dS4np7lK//51Ty+tRLnD/C+szgt5MmDS5ZhtYUzhSqEDKGXGYuEPNTig== X-Google-Smtp-Source: AGHT+IFrQPiKw6OobmPpZC5qLA4y8fmUeUFCa8ZT6AjnEvmq2EY+bnCHZ/fe21c0SW1yQTDnmrNY X-Received: by 2002:a05:6358:4883:b0:17b:5a95:9902 with SMTP id pe3-20020a056358488300b0017b5a959902mr2557585rwc.2.1708531155271; Wed, 21 Feb 2024 07:59:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708531155; cv=pass; d=google.com; s=arc-20160816; b=mayRVE4erJYE8Kx1QVu9fCDOmJiTfzq/sgLmP+cvfBYLPNb0ukZuy6HEGcyiSDjh9n vElWzG7l4nqMm5wja+UiT1AeHMqD0THgHzgKdwnkVAmdVULAOoyzHcugiKglbSn9C6R5 RDLWAXcv1gPDRMSwncTv9c7/PiEILt6EzExrWS2GqEejshfY9VowjXYRD2m4xFgZ7jOF 80j/33Dmc35zVhjFcfikxSGtNkwnjDFgE01GZi6yc2y02AZvl2SUJyFQJHVTo6myVzWE ufAUE99IW64kh8arEV498T+y3aixOtmImDRBTJ/diUNGPs1Liky13InM/R0P+3he5kRw D1QQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=efKwvL9uolpwwXii1YLcblvLBk1Mkbsw9Oy9VotAMtk=; fh=ZijaFjd7KBgla2WfcRBd98vvuWi6mx/fTrVuWg6Gm40=; b=ZOg/Th/XV33WpucPhvdq8g4Bsnikv1/zsCOgX8gIcRACBcFtO5CTOGiaWNUyZKbO9Z FfsfudV5UDdd/ySgf8Zr5wYtlhU/gQ8FWjY8xRNaQCItL1pH+x6vZxBMFKrIur10YQ/s xGo3w7u+51odTLxoPWDUy7lIt1EE0+LNYE6Kq5wnYKVBsTbIp2QoSU95T6jGri8oJn6t LwJgNhnNgyCR2JdESAKo+4CKm8XJjSo+1JOdeiajW9XPNjQnRZGM+s9xDpth0/s1gc2j iTl6+C0JTS01yuATfUAt/nV1Abn6hv0vryi3f1xXgOAcJryobS7icoROIyLeIFDmRVK4 fq0g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mit.edu header.s=outgoing header.b=ki+ifFrU; arc=pass (i=1 spf=pass spfdomain=mit.edu dkim=pass dkdomain=mit.edu dmarc=pass fromdomain=mit.edu); spf=pass (google.com: domain of linux-kernel+bounces-75034-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75034-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mit.edu Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 7-20020a630107000000b005dc8a33fcc3si8388698pgb.653.2024.02.21.07.59.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 07:59:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75034-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=pass header.i=@mit.edu header.s=outgoing header.b=ki+ifFrU; arc=pass (i=1 spf=pass spfdomain=mit.edu dkim=pass dkdomain=mit.edu dmarc=pass fromdomain=mit.edu); spf=pass (google.com: domain of linux-kernel+bounces-75034-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75034-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mit.edu 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 3E12BB25982 for ; Wed, 21 Feb 2024 15:53:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B82098174C; Wed, 21 Feb 2024 15:53:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mit.edu header.i=@mit.edu header.b="ki+ifFrU" Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) (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 E13E280C04 for ; Wed, 21 Feb 2024 15:53:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=18.9.28.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708530782; cv=none; b=EcdioNRONrhHyoAQ0CYigulrVZTb5GOaWmfqYBhZAh8biO6DjRYFsxxnB6JBLYR+PeuyInfMDe8XG9ASnr0B0D67FXyYcKl7jun2+PduavXXRYV1HJI3KUlMDAZ7HZifCwZkYEA6oLhOx1cjgVKqVVEKMrPuEkkJSyWKvxmYeIA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708530782; c=relaxed/simple; bh=Ra9/UKRL6qZi0vZz1rdmAVM+RpYX5dfMa4L3P5pdOAc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=H6OoifpVaMX6gCCjBR/uZGxKwYkaqvtLdUkw0a/SMKd+w3PeWgzwgTq+T11MHjbjTQvdFCb5Zq6XggAF3+7tK4ndXssjTyXLfSi+MABcjWW6XMtaacb5c2g3sp5aeyhD170UH/59DhE0wjC8gzRivuKW4ZqAmWkF6NsoTITg434= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mit.edu; spf=pass smtp.mailfrom=mit.edu; dkim=pass (2048-bit key) header.d=mit.edu header.i=@mit.edu header.b=ki+ifFrU; arc=none smtp.client-ip=18.9.28.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mit.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mit.edu Received: from cwcc.thunk.org (pool-173-48-102-198.bstnma.fios.verizon.net [173.48.102.198]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 41LFpwMs001015 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 21 Feb 2024 10:51:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mit.edu; s=outgoing; t=1708530721; bh=efKwvL9uolpwwXii1YLcblvLBk1Mkbsw9Oy9VotAMtk=; h=Date:From:Subject:Message-ID:MIME-Version:Content-Type; b=ki+ifFrU+r4cRsszgtOQQkvuU8AnK11ChkT5VsV8okX/4tPPZv/N0zZwFcraoxJcX xXwHcov90zmAowqGIJ4yZiC8WPGoFN7WAxYbfa9Ro5H2nY9JOLn8RALnRzQLMz4mXi PSvltheY44N+df/l11hoGrSkvVM6hcD1/kP6+yeFdEQhyNDFO44Bbd0wZ1UBTcOciP Be9ufPu6gYU02l+7GS/I8nF1rQxUALOkWsFfbRtFdYqU6AxKkvhtYccJvCNfFeMbz3 Gl+Ag+qhnQ2MRd5dcj1zcOBxWTNkLXH+uCnhSY/FNrFZxI4pzRF0wr1EZLYHNQO3KQ uJE9Yj0ro6KfA== Received: by cwcc.thunk.org (Postfix, from userid 15806) id DA42915C0336; Wed, 21 Feb 2024 10:51:57 -0500 (EST) Date: Wed, 21 Feb 2024 10:51:57 -0500 From: "Theodore Ts'o" To: "Jason A. Donenfeld" Cc: x86@kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, Borislav Petkov , Daniel P =?iso-8859-1?Q?=2E_Berrang=E9?= , Dave Hansen , Elena Reshetova , "H . Peter Anvin" , Ingo Molnar , "Kirill A . Shutemov" , Thomas Gleixner Subject: Re: [PATCH v3] x86/coco: Require seeding RNG with RDRAND on CoCo systems Message-ID: <20240221155157.GB594407@mit.edu> References: <20240221123248.25570-1-Jason@zx2c4.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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240221123248.25570-1-Jason@zx2c4.com> On Wed, Feb 21, 2024 at 01:32:40PM +0100, Jason A. Donenfeld wrote: > There are few uses of CoCo that don't rely on working cryptography and > hence a working RNG. Unfortunately, the CoCo threat model means that the > VM host cannot be trusted and may actively work against guests to > extract secrets or manipulate computation. Since a malicious host can > modify or observe nearly all inputs to guests, the only remaining source > of entropy for CoCo guests is RDRAND. > > If RDRAND is broken -- due to CPU hardware fault -- the RNG as a whole > is meant to gracefully continue on gathering entropy from other sources, > but since there aren't other sources on CoCo, this is catastrophic. > This is mostly a concern at boot time when initially seeding the RNG, as > after that the consequences of a broken RDRAND are much more > theoretical. > > So, try at boot to seed the RNG using 256 bits of RDRAND output. If this > fails, panic(). This will also trigger if the system is booted without > RDRAND, as RDRAND is essential for a safe CoCo boot. > > This patch is deliberately written to be "just a CoCo x86 driver > feature" and not part of the RNG itself. Many device drivers and > platforms have some desire to contribute something to the RNG, and > add_device_randomness() is specifically meant for this purpose. Any > driver can call this with seed data of any quality, or even garbage > quality, and it can only possibly make the quality of the RNG better or > have no effect, but can never make it worse. Rather than trying to > build something into the core of the RNG, this patch interprets the > particular CoCo issue as just a CoCo issue, and therefore separates this > all out into driver (well, arch/platform) code. > > Cc: Borislav Petkov > Cc: Daniel P. Berrang? > Cc: Dave Hansen > Cc: Elena Reshetova > Cc: H. Peter Anvin > Cc: Ingo Molnar > Cc: Kirill A. Shutemov > Cc: Theodore Ts'o > Cc: Thomas Gleixner > Signed-off-by: Jason A. Donenfeld Reviewed-by: Theodore Ts'o - Ted