From patchwork Wed Feb 14 19:56:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 20393 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1483278dyb; Wed, 14 Feb 2024 12:34:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXL52fjSr2dsj22zwYmr5WBX6OP/EooDr67T8UWp2AW3rvfKmDsTG7vKfTRhIw2eLriklQmHpWWObqFLRAF6K5dCbduWA== X-Google-Smtp-Source: AGHT+IHITUo8hF/BtTTh/9a4InTTky19b1X+5GRi9C3pwD/gl5dN5mKr9DtnG3Yuof71T8z7fICB X-Received: by 2002:a05:6a20:2d11:b0:19e:4eb9:ef74 with SMTP id g17-20020a056a202d1100b0019e4eb9ef74mr5667819pzl.14.1707942857453; Wed, 14 Feb 2024 12:34:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707942857; cv=pass; d=google.com; s=arc-20160816; b=U6/TOneJ/rWoDKcGEK1p+kfJqQb+koyHoeB+ZdA6TpALVIlNTHkPgnUqGCZ3nJIg2Y 1IKwpgydExnP/buUfM3bDDaj70lBD9R2d2ntMM635fySAcBPrCemFkkrs/tUxZONlCb8 IV84lTbe5kAORciC7uuEP4j5MFg3G3nOB8Z5Q013U9cWPKC6CTTGGzOnPePWr05OMuGp gMrefRB4zHiUfr+d1/LR6GTwQZQ+zG4t4LbjKLpxqtJc4CAVuit9INKhC0X6LJc6L/aC LsEf84JiXhTv04Y0kZT71wfN6F0wfLckGZFp5DByQ2MiOWgTKZ+H5FimmBsMUIdzC+Qh fdqg== 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=VQZbV1ZRSBfDzNEzlHptd92Qt3munE/+2UoEimi5XdA=; b=V0XzDe6e9pKPLcfXRqc3BsA8hIYtUbDShwsDf9VdrN7GQ65u0DXfhS4LCFdxSEpLJM +90Jq/KXAEzPYauPvWidaGqCwxBEQs5UY7BnmXCARAfKBBScCAk1vDoSpTVWw2RJPEZf uta7TyJ0yeajjM/1qKzDnFewyBIBtFmrVj0OFV0XUZO5TnTbYHO4fwepfxtclZPaXWJ0 uMIs5UdlYa0A0zlVtgtzg3JWzkFYZGOM1BLG44H3XTy1FLH8/iqgjIn4LQQxY8+GpeTj udy0YWUS87hV4zBUSPBT6QyJlgRmnYbXhRb+gvjJGYU9wmZX8jPyL7vUC1n3vX36azmI v2Gw==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65904-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com X-Forwarded-Encrypted: i=2; AJvYcCUyUIurcfhhx5Tq1Dz3jZDq4wKgnDpRhueC1wKTXWx9bE9Y5zOdB+wNmw8R8qm4hUGOsDBRZPBV9ijTgbXdCVThiD04ZQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d63-20020a633642000000b005cdfb96ea62si4200741pga.243.2024.02.14.12.34.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 12:34:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65904-ouuuleilei=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=@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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65904-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id DB98AB28C1E for ; Wed, 14 Feb 2024 19:58:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AB74913DB92; Wed, 14 Feb 2024 19:57:57 +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_P_=2E_Berrang=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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790907889933876328 X-GMAIL-MSGID: 1790907889933876328 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(-)