Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1180615rdb; Tue, 30 Jan 2024 10:06:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IGEKS9hpRdCqg29a89X7PPavSHa2IZfUJ9+5L2NSLmKBj6z/39ctL/ZikfHpxCFsCMYDlaX X-Received: by 2002:a05:6808:17a5:b0:3bd:9a04:80a4 with SMTP id bg37-20020a05680817a500b003bd9a0480a4mr6113888oib.48.1706637985299; Tue, 30 Jan 2024 10:06:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706637985; cv=pass; d=google.com; s=arc-20160816; b=ITdQwYwQhQdysowTcZrVlAa43X1/BiX7yAxivCAwkL92k6VKxKiKu69XXtiVZrJCwR 1K7JJWEJa71qkyqblSC0TpcIxRyiDw/APU5kOtW2S+nFh/biMVHsffOHUvbWMAqEuZ5w jEpvVFSuUZNutXnTRqJwbsAQmH6e1RsuZ1lw9FmydIfxIO/EdHs4haKYwHfpg6E4LVu3 vvnonr8aH3cYdIrkVkOSad+pZblCOPaCzRI3klbjHxCUDwzM6YdEAXUiL6tjqIRx/+bA kxntdDpA9JabW5PtD31U/EtEPiDZdFMzpXxW3cHG6JWeKQ34P4rezITsjIVthPSjA3ts wGUA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:references:reply-to:message-id:subject:cc:to :from:date:dkim-signature; bh=J6NBBIOV0mk2VOcCkKd1idr5TUMKX7QhfRR0ebMmJ3Y=; fh=3unzUQ9taYi3CvUEFAG6rh/dE+iAVauPXlhq97wP+JE=; b=hYM6nB27Gfqzt1Pcounp5JWvPPGVhUsOTxPDWe1N3rCJuALWf3wgAjQ1FVHfqIKhQp 7M84WEy8jbuHgZZUyKIbcFgzJ3PAvc1TN34xrPs2zJ6UWUqvtvUm4Lk/uSD337uSUock yB/X4A78AgFcuJtagQGdbO64KXMVJcdTEJpGI7uE4rIBwm77i9h6yhRgF2gWdJLWniWo /WVuw/xYrivUfjJdZPo7IdQgsEp0w/nW7hzhwN7+lKT+DZ763N904MBPOvk9Fj4ScKxw fZ1PKNJPNtdX1KXjuruTY5jwnJNKESO6FoegkqLVSSi6Ylt2gtAPxoN1LPYjc23r01aT eY2w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bkIyaz+F; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-45078-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45078-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w9-20020a67e249000000b00469b9f391bcsi1163790vse.449.2024.01.30.10.06.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 10:06:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45078-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=@redhat.com header.s=mimecast20190719 header.b=bkIyaz+F; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-45078-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45078-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 501C11C22CD8 for ; Tue, 30 Jan 2024 18:06:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 59140155A5B; Tue, 30 Jan 2024 18:06:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bkIyaz+F" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 9E3E186AEB for ; Tue, 30 Jan 2024 18:06:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706637975; cv=none; b=awi2QdxQDM2ci5Xo3nJC2vLy658ximGPBxoFPeu/lyIt/IQ+gPgKJSuC9+s3lRjfGWULT4+4rwLryS7LHdsz7a7fM577fDrI6FR8gUfYVNqc0hkIqj1uKAw9Kqlid1OUvTXxSh2/leXTenzzAIh5fIZ0FUHA/nh8R6GE9LUEyJ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706637975; c=relaxed/simple; bh=zkh4gbx/89GnNbOgA+ve9IJXox6oRxmTjSJ398w+CDo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ihLgACZp2VGjGioVgzS1BJT0d8hT2C6xOaNZxD0dKct9vKQIfdS5EX58jFPs53qImRS0UDRiwxCAIIU13NbW+hDB7fa7Axx4acYmyynWq7xiA8h332SAFV7ZUWEIFVgkw8ggDro8xMlG/4VZNTj0PBjGBjUBUwFYW6/ALiSP4As= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=bkIyaz+F; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706637972; h=from:from:reply-to: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=J6NBBIOV0mk2VOcCkKd1idr5TUMKX7QhfRR0ebMmJ3Y=; b=bkIyaz+FogO8emnnMnEXY0vuqJAyaJp8hYt0R5BUB7Z9YbEm5Yb8rLqUgyLfrwOklp4QUN WVc6VmWY2qZM9Nh796YKoYEPjMlETLOqrVzhLULB6+ua+7heEKrwFdeeiR7RY/s7bZudvV FO8Wba1+FTdEy1kxVoZV0iw/mBCILcc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-118-aQRKw9BIOK-k7XQnCGSVeg-1; Tue, 30 Jan 2024 13:06:09 -0500 X-MC-Unique: aQRKw9BIOK-k7XQnCGSVeg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5A5D1185A787; Tue, 30 Jan 2024 18:06:08 +0000 (UTC) Received: from redhat.com (unknown [10.42.28.52]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 28B4A1C060B1; Tue, 30 Jan 2024 18:06:02 +0000 (UTC) Date: Tue, 30 Jan 2024 18:05:59 +0000 From: Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= To: "Jason A. Donenfeld" Cc: Dave Hansen , "Reshetova, Elena" , "Kirill A. Shutemov" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , "x86@kernel.org" , Theodore Ts'o , Kuppuswamy Sathyanarayanan , "Nakajima, Jun" , Tom Lendacky , "Kalra, Ashish" , Sean Christopherson , "linux-coco@lists.linux.dev" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 2/2] x86/random: Issue a warning if RDRAND or RDSEED fails Message-ID: Reply-To: Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= References: <20240130083007.1876787-1-kirill.shutemov@linux.intel.com> <20240130083007.1876787-2-kirill.shutemov@linux.intel.com> <88a72370-e300-4bbc-8077-acd1cc831fe7@intel.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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/2.2.12 (2023-09-09) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 On Tue, Jan 30, 2024 at 06:49:15PM +0100, Jason A. Donenfeld wrote: > On Tue, Jan 30, 2024 at 6:32 PM Dave Hansen wrote: > > > > On 1/30/24 05:45, Reshetova, Elena wrote: > > >> You're the Intel employee so you can find out about this with much > > >> more assurance than me, but I understand the sentence above to be _way > > >> more_ true for RDRAND than for RDSEED. If your informed opinion is, > > >> "RDRAND failing can only be due to totally broken hardware" > > > No, this is not the case per Intel SDM. I think we can live under a simple > > > assumption that both of these instructions can fail not just due to broken > > > HW, but also due to enough pressure put into the whole DRBG construction > > > that supplies random numbers via RDRAND/RDSEED. > > > > I don't think the SDM is the right thing to look at for guidance here. > > > > Despite the SDM allowing it, we (software) need RDRAND/RDSEED failures > > to be exceedingly rare by design. If they're not, we're going to get > > our trusty torches and pitchforks and go after the folks who built the > > broken hardware. > > > > Repeat after me: > > > > Regular RDRAND/RDSEED failures only occur on broken hardware > > > > If it's nice hardware that's gone bad, then we WARN() and try to make > > the best of it. If it turns out that WARN() was because of a broken > > hardware _design_ then we go sharpen the pitchforks. > > > > Anybody disagree? > > Yes, I disagree. I made a trivial test that shows RDSEED breaks easily > in a busy loop. So at the very least, your statement holds true only > for RDRAND. > > But, anyway, if the statement "RDRAND failures only occur on broken > hardware" is true, then a WARN() in the failure path there presents no > DoS potential of any kind, and so that's a straightforward conclusion > to this discussion. However, that really hinges on "RDRAND failures > only occur on broken hardware" being a true statement. There's a useful comment here from an Intel engineer https://web.archive.org/web/20190219074642/https://software.intel.com/en-us/blogs/2012/11/17/the-difference-between-rdrand-and-rdseed "RDRAND is, indeed, faster than RDSEED because it comes from a hardware-based pseudorandom number generator. One seed value (effectively, the output from one RDSEED command) can provide up to 511 128-bit random values before forcing a reseed" We know we can exhaust RDSEED directly pretty trivially. Making your test program run in parallel across 20 cpus, I got a mere 3% success rate from RDSEED. If RDRAND is reseeding every 511 values, RDRAND output would have to be consumed significantly faster than RDSEED in order that the reseed will happen frequently enough to exhaust the seeds. This looks pretty hard, but maybe with a large enough CPU count this will be possible in extreme load ? So I'm not convinced we can blindly wave away RDRAND failures as guaranteed to mean broken hardware. With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|