Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp38618rdb; Wed, 14 Feb 2024 11:58:26 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWxuuKWdjH7c9fq9nsJsKl3wgBaYdE1sAORaMqwk9BGQ6smZaah8a3NrrEBYImJsRTElCHpgIQxIkIWlQ5vjamtCDWlz9F6tDkIDSGz8Q== X-Google-Smtp-Source: AGHT+IGfyu1xLQBg599V3d0LAzpojmZFzsr9TLiOjBq9a4PRiAUAORQkmzF9Cqt+wVGtJw8a2pBz X-Received: by 2002:a2e:9442:0:b0:2d0:cbeb:7087 with SMTP id o2-20020a2e9442000000b002d0cbeb7087mr2635942ljh.27.1707940705912; Wed, 14 Feb 2024 11:58:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707940705; cv=pass; d=google.com; s=arc-20160816; b=ienlrBX+W8kuY4ftOQGCN4IGagjZzI8R8Dggwuom4jyyWCxLoGGPVmPkE7c/xl9FoW oYz2HhfMJK2hRjf1DA0xt1LGEjkjwsJL26W1gpcBYlzYuuvYPclkecVFSvrtSzwhVgeE F4b1Ep1kizWhagWMTkRX6yYM6Wc2yrTyl9YKkOBeH9hML5V/etJDySjlpnK9rsEbdtMA b+YxxLTHe94sQpNzTewU+hzdaMfyWMGSRHGSK9r8u5Spe/4adgt+qMw26ibhn+EQk2xN KTE8xoYJy8N/vajXDGvi6As+Vwqh18xlPSQGqEQ8wc5Mr8rQ+iXhSIdvjZULqedLetfq LLpg== 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:date:subject:cc:to :from:dkim-signature; bh=EBWgH/bJ48TOitK6Vt3KlSbCS2O18SAPEqKWNkp++qs=; fh=aBl/EVlLJa9Eq1cTKO01R1ldakFD/X351DBTjfc+K/I=; b=q8Q7M/y5R4wn+bPDffu+cSP5bHgKBJdrveOMH8hsYqkueWBZvvo6d55VDxKCN7LSbh YaM8GUg2N++wchZLcNsyiWgGTGALMXX42WQjCrxM6Y42gWDL8yVg2uVTvHRrEzxv9jZ4 VsRHBrFhGoEABnG0cNINL3FOrVJ9aAj4HNt1TUQlRPRmqNHyqdmS60EOCSwzrKlHoZkr fc8go6QOIHQBv1PBn0HqjSGwWrtixUlpcAmHlgv2b35+/EHIon/VbhJi+k+TKg7EJoRc +8vNj0nYCfazXRy6H7CnDssr7r1RSeDU8tPuG5YSprOMQXP8nUQV8OcvGSgGqfnx5UII xjaw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=We3T8zLR; arc=pass (i=1 dkim=pass dkdomain=zx2c4.com); spf=pass (google.com: domain of linux-kernel+bounces-65904-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65904-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com X-Forwarded-Encrypted: i=2; AJvYcCVc3+YPiqVimHtgZrjWAdY7AySItL/yrnHb22tG+qFNAvEjSguESWES7CL9oCpQawwqhOQikoZMKoaBHd+piqj39aHG4CCmAJamnOkdbw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id cm3-20020a0564020c8300b0056389c2b8f8si575604edb.360.2024.02.14.11.58.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 11:58:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65904-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=We3T8zLR; arc=pass (i=1 dkim=pass dkdomain=zx2c4.com); spf=pass (google.com: domain of linux-kernel+bounces-65904-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65904-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 75E341F24A5B for ; Wed, 14 Feb 2024 19:58:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E98DB13DB8F; Wed, 14 Feb 2024 19:57:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="We3T8zLR" 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 18C3A13DBB7; Wed, 14 Feb 2024 19:57:54 +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=1707940675; cv=none; b=etgGNSYQk18MexhoBmyTCQSFC+L81n6HCp6qYo5v9dpi61ZIonlSrP/kauPii9YXupqxSUoP0+iCYPqxWPxiCFVsAnn7Vg3+hXRTqpVqvlbRpOf6FTJrY8dS1K7afsJMgglMMqCdr9+vyPkQ73D8VB4cu210ODPyrCgJCCnQ8iI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707940675; c=relaxed/simple; bh=JObSMzd6HvbxyZ7oi2dYfoS+BK3H8zc/IpUDq+NI1aA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=rMOHPxgDHaJU5wZeY402WEIAQ10+wSYc0ZN+Hve/y6BpAlXaHjnKwg5VSIvIOM61rlqoTqCo+WQwpMQU3J6txiTl9a5ATBlEPJDOqgjH6LfwRqFoOUQGc1A/iLZQmtEcNs9N054Lm2iBSJbEGkknbk6+GuCfaDoNacj06xQGEr0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b=We3T8zLR; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 654EFC433F1; Wed, 14 Feb 2024 19:57:52 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="We3T8zLR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1707940669; 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; bh=EBWgH/bJ48TOitK6Vt3KlSbCS2O18SAPEqKWNkp++qs=; b=We3T8zLRQ/yIJ9kKCOZn3FPO7zMrdzBAjxqcziriLpa3MLC1FYMrVvaaTNUCtA4/G60Sx4 1a1c0efcte5Y5dXbLc5PKdVsKu/sOPBeU18X/r9qLHuFuLxOBVkHn05RVoyvBRLKe6wPia xth+hOo7NokZTBtmz7AAZBYVUH1wjbc= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 2f6abd26 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 14 Feb 2024 19:57:48 +0000 (UTC) From: "Jason A. Donenfeld" To: x86@kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org Cc: "Jason A. Donenfeld" , Borislav Petkov , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Dave Hansen , Elena Reshetova , "H . Peter Anvin" , Ingo Molnar , "Kirill A . Shutemov" , Theodore Ts'o , Thomas Gleixner Subject: [PATCH v2 0/2] CoCo/RDRAND brokenness fixes Date: Wed, 14 Feb 2024 20:56:46 +0100 Message-ID: <20240214195744.8332-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=UTF-8 Content-Transfer-Encoding: 8bit This takes a two-pronged approach to the matter, now that we have details from Intel and AMD: - In the generic case, if RDRAND fails, simply WARN(), and don't try again. It turns out the "try 10 times" thing isn't actually a correct recommendation from Intel. Since RDRAND failure implies CPU failure, a WARN() seems in order on all platforms. - On CoCo machines, where RDRAND failure implies the whole threat model is compromised and execution shouldn't continue, we ensure that the RNG gets 256-bits of RDRAND at boot, or otherwise fails. 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 Jason A. Donenfeld (2): x86/archrandom: WARN if RDRAND fails and don't retry x86/coco: Require seeding RNG with RDRAND on CoCo systems arch/x86/coco/core.c | 37 +++++++++++++++++++++++++++++++ arch/x86/include/asm/archrandom.h | 18 ++++++--------- arch/x86/include/asm/coco.h | 2 ++ arch/x86/kernel/setup.c | 2 ++ 4 files changed, 48 insertions(+), 11 deletions(-) -- 2.43.0