Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1150331imn; Sat, 30 Jul 2022 17:47:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR4NYNqTVbGUGE0OE5zgIMLWPyhWm3tPbFzBFtiu4TsdKQQ/2EIUIgoax0urY0jWRMn/jXkM X-Received: by 2002:a17:902:8bc5:b0:16c:f48b:d5b5 with SMTP id r5-20020a1709028bc500b0016cf48bd5b5mr10583659plo.128.1659228468021; Sat, 30 Jul 2022 17:47:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659228468; cv=none; d=google.com; s=arc-20160816; b=LZSW0lu9L+DuU6SQ2ihgkw3+I/k9QQtviL+6dEZpZPoCeaELpMvtxcxRbtbSjcqgA+ XapH99rEK/nzKEH5rIHwA8YeOlWi4sqMoGL+LHNsobEDDT5clESPoDOJryLDHwLN3h4O up7NPzoNG7sFNTAEBzKBvtC9+inHy0vwGoGomiJDJlqBmwLTZdvattNV47wGinwrfJbk I1GfMKhfPPU5doQLsce2EzURA7zJtmrDKix9qjQbrod+a5tkKc9us9K1wC0+Djyl6FcT 4UeRj27HZ7rlVPz3h9WlzSNp8sLtuT8asNIfKep65mDgZj2qtnsPxwG8g0VKupFHPhtt eyUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=27908CkDTCkHGm34su8KkauoS3hA0gJGr/pZJ+wqutM=; b=Y9/axoexRvCqj7pmnQOJUH7ElFatgaC9aJp+oiQtbec1n0ul0kF/XnRAXm1+CSBIr9 1BqeDPMOcio6mt9P6PeHS00AlIUHX9DHO5iAUuX11QFVIRZ80HQ81SfnoXUz6SPjmwkG XdWm/POtpAyjWBFsOdP6SICnwUrzXhJM9+Qtgnn222l5RMu9Ax0E8e8fDCTpx6usnDpQ ToIrUoa01HM+LFCqbvS/6aViyVNIHOD7hlyEYYqG8vlNXsZChMfhzXCwpW5njGypbyr7 mLpfs1qJqPcD6Vaq9DUJnKopOKI5RkUllNwIoUJ+5ZMFGtRCbVDcrJbbH3LWNjq32zzy mpMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=VyTLLn82; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p4-20020a056a000b4400b0052541302f29si2523273pfo.359.2022.07.30.17.47.16; Sat, 30 Jul 2022 17:47:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=VyTLLn82; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231175AbiGaAYA (ORCPT + 99 others); Sat, 30 Jul 2022 20:24:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229737AbiGaAX7 (ORCPT ); Sat, 30 Jul 2022 20:23:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49EE51400C; Sat, 30 Jul 2022 17:23:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CA911B80C85; Sun, 31 Jul 2022 00:23:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 476EBC433D6; Sun, 31 Jul 2022 00:23:54 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="VyTLLn82" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1659227032; 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=27908CkDTCkHGm34su8KkauoS3hA0gJGr/pZJ+wqutM=; b=VyTLLn829hnIWtizj6XvTyYJpAwMvhg3tRSzGUX1NkczihOKfrQX5dVLRtpfFGg+ETgCTz 87gNFzZ8snfNdyglSWE3X1I0XzsCTm//en0RigzOHU59oO0x/KOKiMkPv6RJwQ6DwH2AHz HHezJoIJUxJ6j3aJXvJzMYu6PP95cWs= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 858c0c7c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sun, 31 Jul 2022 00:23:52 +0000 (UTC) Date: Sun, 31 Jul 2022 02:23:49 +0200 From: "Jason A. Donenfeld" To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, x86@kernel.org, Nadia Heninger , Thomas Ristenpart , Theodore Ts'o , Vincenzo Frascino , Adhemerval Zanella Netto , Florian Weimer Subject: Re: [PATCH RFC v1] random: implement getrandom() in vDSO Message-ID: References: <20220729145525.1729066-1-Jason@zx2c4.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Sun, Jul 31, 2022 at 01:45:43AM +0200, Jason A. Donenfeld wrote: > So, anyway, if I do muster a v2 of this (perhaps just to see the idea > through), the API might split in two to something like: > > void *getrandom_allocate_states([inout] size_t *number_of_states, [out] size_t *length_per_state); > ssize_t getrandom(void *state, void *buffer, size_t len, unsigned long flags); > > User code will call getrandom_allocate_state(), which will allocate > enough pages to hold *number_of_states, and return the size of each one > in length_per_state and the number actually allocated back in > number_of_states. The result can then be sliced up by that size, and > passed to getrandom(). So glibc or whatever would presumably allocate > one per thread, and handle any reentrancy/locking around it. > > Or some other variation on that. I'm sure you hate those function > signatures. Everybody loves to bikeshed APIs, right? There's plenty to > be tweaked. But that's anyhow about where my thinking is for a potential > v2. Doing this also doubled performance, perhaps unsurprisingly, as that getcpu() operation wasn't free. For uint32_t generation: vdso: 25000000 times in 0.289876265 seconds syscall: 25000000 times in 4.296636025 seconds