Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1124572lqt; Fri, 7 Jun 2024 08:38:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU1UbSMtGx587BCkhp+RYWb9kUBRgZF549+3m6KioPAvuEbArqXldJWy+bV3OJK52JZWAI96iYPr0bIjUFTk94dKZrVzZUzxE/gTnQ4ew== X-Google-Smtp-Source: AGHT+IHYnMHexI6c7Arkc1PaBNEICZtVVU0RWbv9936zhtvv6SdZg3PjnwIU6BR8Gq/LsVadni3p X-Received: by 2002:a17:906:3b87:b0:a5c:e372:222e with SMTP id a640c23a62f3a-a6cdaa07a0cmr220533366b.60.1717774696465; Fri, 07 Jun 2024 08:38:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717774696; cv=pass; d=google.com; s=arc-20160816; b=TC198iOzuq8ncdOMPNUE7Glff3Eslry2k6qjps1zrwEwNBazFAeeVSaom9hX/TIu2s 8AT10GNbSNEExpbJ8D6Mx6dQO4Q49ydF+34Eyv4apmosWDjFc47wHLxTzG2Kf1BLR5pV dhHDIYMla3YrVW4l1uPe+QHhAXwQt5pu0+hMUNBUvVhHc3LiSCp53ytWfw+SKxhB1Ahs 4i0yCXOtSIqc1FwNmP9k9zlpU8NV2HeRQ6meQOcuTevgO2zdzaaHtYc+hRa7esOG+krS +9GADgL97hT9z8FL3AJ5twyWhZ4bPwljxzeT03NDCrnPqFcjzWODKSta359FjDuAQaE/ C+EA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=VdaGblx7cL5MU4wq83z4MFvGPW2Ec6PER4ig9UlfUIU=; fh=4oBPUnbWZDyfZKt4JfhvC1vFAkZQKvNrfVDRE8h0a+w=; b=TgfCVjRPW0NcaEhC9mwr5//iZkY3raovgQ4efCubVFkHBzNj8YHK2Bf8AADujkR24I dG/Gdx1NwcC9FxpB/ixfKWjMp4nHiAujDvxwA5YH8PG3dR30ubLBMyIB5tWnooIm2siB aRqeL41y+eN88yT9Ey5ptGrxaaVTAHEA7XWTnSsfWCvcvMV89s+dn90QdVj2pumby7w4 sJWR5gszPTGsEzdUX/Quh8enqWsM4nPrjbc2AOZZUu367DekpusEs55EryFfDQFFRupR hJM4R8Xd7klB5k1g8sjwNaTDJZ7ApvqMKrBJUDe/ytFRLOkTaaVnx8/6ZnadThhNiQtK Hj2A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=i3V0bmVM; arc=pass (i=1 dkim=pass dkdomain=zx2c4.com); spf=pass (google.com: domain of linux-kernel+bounces-206412-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206412-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6ef449670dsi40441866b.504.2024.06.07.08.38.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 08:38:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206412-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=i3V0bmVM; arc=pass (i=1 dkim=pass dkdomain=zx2c4.com); spf=pass (google.com: domain of linux-kernel+bounces-206412-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206412-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 312FA1F21701 for ; Fri, 7 Jun 2024 15:38:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A55C1171BB; Fri, 7 Jun 2024 15:38:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="i3V0bmVM" 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 B2BAD61FDD; Fri, 7 Jun 2024 15:38:05 +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=1717774685; cv=none; b=sdGsfLdOQxWRFoTXtLekGtCnnIflUgtFq/da8i7bqiQsSCPkH1K1XEDjJmxYe5CYTG4EQmmJ3GwQ0B8O/8bok4rnVS33y6dVWvzUMJPenI+uyWx+QdSJyahg6zsIrZ5nmi7xilKTxsbM+CXQmbDlhwBInE29ZkTlNcSXGfQb1uw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717774685; c=relaxed/simple; bh=Il9y63ujbF3nbi7YEEuhQJ7RdIMFbVF8NRlUr4A3cdo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gpMqvh1o/m/1ayf6XiiDa3GywkKAL/7qe55VungMZNP3tn9scjY7ukFI8Duih2YoQZOZwmxUG1bhoa9YaXVjycaHBeuJ9WY06RabvcCaKhE817TgiRAChz41/jWG5DCvtwKlyU3O47tBqyZVNShfxhszR5A9KU9MUVjemwz4s7s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b=i3V0bmVM; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9163C2BBFC; Fri, 7 Jun 2024 15:38:03 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="i3V0bmVM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1717774682; 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: in-reply-to:in-reply-to:references:references; bh=VdaGblx7cL5MU4wq83z4MFvGPW2Ec6PER4ig9UlfUIU=; b=i3V0bmVMvJ33qmlfTcRb7iBAdeclk+HZiq3BXLZHOQvsgY0dh8qjRajQ3/ICbNZuNaLILc IAcOap4dKE8o79NX7E911c/1d77t7tlWt4I57NtloaVtIbNhZapuLhLdf1C9QyRWm6x/J2 ZKxQFpb7uy9QJXd+IwOL10HqEN1KSJ4= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 0fa858e9 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 7 Jun 2024 15:38:01 +0000 (UTC) Date: Fri, 7 Jun 2024 17:37:55 +0200 From: "Jason A. Donenfeld" To: Randy Dunlap Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, tglx@linutronix.de, linux-crypto@vger.kernel.org, linux-api@vger.kernel.org, x86@kernel.org, Greg Kroah-Hartman , Adhemerval Zanella Netto , Carlos O'Donell , Florian Weimer , Arnd Bergmann , Jann Horn , Christian Brauner , David Hildenbrand Subject: Re: [PATCH v16 4/5] random: introduce generic vDSO getrandom() implementation Message-ID: References: <20240528122352.2485958-1-Jason@zx2c4.com> <20240528122352.2485958-5-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-Disposition: inline In-Reply-To: On Fri, May 31, 2024 at 12:15:16PM -0700, Randy Dunlap wrote: > > > On 5/28/24 5:19 AM, Jason A. Donenfeld wrote: > > +/** > > + * __cvdso_getrandom_data - Generic vDSO implementation of getrandom() syscall. > > + * @rng_info: Describes state of kernel RNG, memory shared with kernel. > > + * @buffer: Destination buffer to fill with random bytes. > > + * @len: Size of @buffer in bytes. > > + * @flags: Zero or more GRND_* flags. > > + * @opaque_state: Pointer to an opaque state area. > > + * > > + * This implements a "fast key erasure" RNG using ChaCha20, in the same way that the kernel's > > + * getrandom() syscall does. It periodically reseeds its key from the kernel's RNG, at the same > > + * schedule that the kernel's RNG is reseeded. If the kernel's RNG is not ready, then this always > > + * calls into the syscall. > > + * > > + * @opaque_state *must* be allocated using the vgetrandom_alloc() syscall. Unless external locking > > + * is used, one state must be allocated per thread, as it is not safe to call this function > > + * concurrently with the same @opaque_state. However, it is safe to call this using the same > > + * @opaque_state that is shared between main code and signal handling code, within the same thread. > > + * > > + * Returns the number of random bytes written to @buffer, or a negative value indicating an error. > > * Returns: Ack. Thanks.