Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2434903rdb; Wed, 21 Feb 2024 07:36:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV0sOrQSpkHbehe1zq5v+wfRidZSqciSDAv9SK+0aLNsAE6xbLYFnrnRDkjXC0ai63MY5VStPVPQqBwMNIRLU8yGBVS6DS/Zh3DJgzvQQ== X-Google-Smtp-Source: AGHT+IFs79Ev2ofpdQKKtrpqfArR87mQXqkiWxa2QowfeoYYE8Z6+isUarBBZRuChXaxTsWa8ORr X-Received: by 2002:a05:620a:31e:b0:787:2b5c:e9f with SMTP id s30-20020a05620a031e00b007872b5c0e9fmr19186448qkm.14.1708529788344; Wed, 21 Feb 2024 07:36:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708529788; cv=pass; d=google.com; s=arc-20160816; b=MP9G6lOjl/DjKKMF1PRF2FEy6kvQqip588hLdVQqgRSnggpX0z60RN/i8hX8z7AFdn 3HWprs5u2bgdX5kc1Liim0CrJedxXCoo9IUL5otiWYD0IlD+nPlU29qid3A2H9gknBhu Q+b91nEEUvf7qQyagHraFcL/+AV2ZbOmBhc3Yy3N9/hNH5AJh2TktKcU5eg0/yJUJ3GK IZHmGpkf/vckEOLKUduDX0dUcq5gXpips1Bw2ApzB/q7yBIfXZM59wCzjRCTBCBnvNfT JtFRy2PDfzQRSmQOsZIxzbwSyZ4whdeGnM4bM4Bqq3rRf9GmF8zGdx2aDJfryTAxS8JP H1YQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=jz7bQ0RRoK61Cw9zhVIJUimC34X5/mo8M/CW0Rqtf2w=; fh=pk0Xl6CQfgUkzW5PLoxt8xop/E6cDWqKOvxNp4II+Aw=; b=JDIicqdJ0ljN/67WprQNKWSrB7YiODgC+ISiL+eiVPBlPgVlwuBNAn5oJ6czVPNiUt OYIb+1sItyvECngjseFbfi0iTEV9LIFkAuJPjtNlO2oqNoZIx6eauyCcI13OXNaTehsg Pt7prDuLVW6R+t6IjvEoUGCjV/dgerDv0+rjvKNo5680xejaPSb81SEtVNxlMv41Szov UW0OXM1LOvwmy0i/qUfWez057IH66Zp0RmSsOF+o0ueWKgpHPY1KBQzHNEqk+nRDbr07 Cj7hQtvzX9RyrZg8FZKg+mdyKWSqfECdoyNafJUZcN9pPfo+Av1KveNUB0KbGXDOd419 OJgQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=fbRqzzI5; arc=pass (i=1 dkim=pass dkdomain=zx2c4.com); spf=pass (google.com: domain of linux-kernel+bounces-75004-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75004-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a7-20020a05620a438700b007873adcd28esi11974073qkp.231.2024.02.21.07.36.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 07:36:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75004-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=fbRqzzI5; arc=pass (i=1 dkim=pass dkdomain=zx2c4.com); spf=pass (google.com: domain of linux-kernel+bounces-75004-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75004-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 0DCF41C239EA for ; Wed, 21 Feb 2024 15:36:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0174A8063D; Wed, 21 Feb 2024 15:36:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="fbRqzzI5" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 240267FBC8; Wed, 21 Feb 2024 15:36:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708529782; cv=none; b=BeQsfb4Xlxsu1CoEiQnzYZ8ce6M/RXuqA+7oqN6LI01bEc5Cjw9KLa7L32XgI7pXOyfQMT2spS+8FStS3NRFHM2y6hmpNAOxFCOTraE/nOanpM+lkQfI/nIKbcKfGHSXKU+x7l/V854/zhX0P0rCHVt//h/CdojVjYE/NDn6hzk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708529782; c=relaxed/simple; bh=jz7bQ0RRoK61Cw9zhVIJUimC34X5/mo8M/CW0Rqtf2w=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=sE7j8q5DAkwubBgWp60IjI3HLPeiVvlP/4k1e1rldgkC1HTLXAD340B0q9TXdtGjpECZnYUg0D+Z4VK29jz1ROputhJw4mEsul5qD/ith9GCPmAsYhP+9m2sPu5lOKMqrFBxjeYdlGvPRNQkIyZQH3hUNUUBjehHq98r2TOZ/Js= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b=fbRqzzI5; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 477ABC433C7; Wed, 21 Feb 2024 15:36:21 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="fbRqzzI5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1708529777; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jz7bQ0RRoK61Cw9zhVIJUimC34X5/mo8M/CW0Rqtf2w=; b=fbRqzzI5dot6PF85I/FDqACOB44aW4zyUYsUhILas048I9XMxDJZ8gU523UWwrqfVu11V9 pTlvCiX+GRlMt5gB7OgU85ckQGSayWvmVIYEuxEqub7J839hk1WIh3HII4BBaVWSoOLx6A Y/e3hwQXECdZ8MRdBwnXrjDep6Du0cM= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 996651aa (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 21 Feb 2024 15:36:17 +0000 (UTC) Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-607e60d01b2so29073267b3.1; Wed, 21 Feb 2024 07:36:16 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXJbQTPNyfQU5EwAN+CFlDlDXlSxtISFqkQEeTJaUKphpcxxweLMUtxgyVsrzdaZxZbzz+RBxy3t7sj9UUMYiq77ynMYcb4qMQjBUYMJa4KTnJ1LylcXK7UUQl0mIjP2p+xK7rh X-Gm-Message-State: AOJu0Yw59w1q8rZKapHUHkNC5f/QFlPOgmsqAgFoGsNZStelJH7qh+W/ uTFCHwdf6UA2q5WtkKB7RidMLpqo0L5WExjiNWQ40UmjdgfI/vI54aYZcl8XIMquxGh378jfnKw hSlkGXKV+wGwYVi96IyxCbb7nr9A= X-Received: by 2002:a81:df02:0:b0:608:8d57:368c with SMTP id c2-20020a81df02000000b006088d57368cmr840841ywn.49.1708529775977; Wed, 21 Feb 2024 07:36:15 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240221123248.25570-1-Jason@zx2c4.com> In-Reply-To: <20240221123248.25570-1-Jason@zx2c4.com> From: "Jason A. Donenfeld" Date: Wed, 21 Feb 2024 16:36:02 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3] x86/coco: Require seeding RNG with RDRAND on CoCo systems To: x86@kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org Cc: Borislav Petkov , =?UTF-8?Q?Daniel_P_=2E_Berrang=C3=A9?= , Dave Hansen , Elena Reshetova , "H . Peter Anvin" , Ingo Molnar , "Kirill A . Shutemov" , "Theodore Ts'o" , Thomas Gleixner , stable Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Feb 21, 2024 at 1:33=E2=80=AFPM 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=C3=A9 > 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 Also, Cc: stable@vger.kernel.org At least, I think that's probably what we want, though I don't know what version range is relevant for CoCo.