Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1838305imn; Mon, 1 Aug 2022 01:52:55 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tTH+3DQ16+psTatzkZFxVzAlpN2dlgnGIc6s7o9XXEBWRgvYo/9rXMgxHt/iUNZ2b0utCi X-Received: by 2002:a17:906:5a67:b0:72b:610d:4aa4 with SMTP id my39-20020a1709065a6700b0072b610d4aa4mr12048045ejc.294.1659343974991; Mon, 01 Aug 2022 01:52:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659343974; cv=none; d=google.com; s=arc-20160816; b=FQ4Dx8Z8EvzUR9FfS0nHKa1IvPNabT5BnpYFwrRyvMdsunkfBMnFE5+HyCa/2CupCv XCUXEHCCQ/69Lp4wYjUOwyY80pN8ENu+qmncS7ZzT0rnoQqzZB1kNWuXn+YhO+f1i1nz rkW348GVSt6mN3mj2mQsAGQ3FkBo07WaIZcbARaZa6cKVvG+9u8wejmR1E8sXfBZuKGP bzi96QtoH2xMsYyhrpu5ijR/ZTLT5MTaCgLDFV4Rvl8tc6Y+m8pHmfq7oxWUrbOnN+m9 7UM9hzB7WrfF1lhozGPsF7OrrXBMIXsr4dyPSZiXv416cNit+XTZ5xL49NNR/jMl0ubF 57KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=BNJ0qfYYXdwgVW9QwtcOifyrJ9WJ2qkCp4TWBgANzYE=; b=pQxpaVJwmfE/ont+i0d/oC1t4Kz7wTunnOsH4ZtUTZoJeD+k4PaO5/1cEgvlt5lCeT YoqUdE36uDe/f+Fh+bl1jCPPpJBbybZUOt8o+epCMpEx+qgXlZ/thK+dB1sGNjCmaeZW ycySpmmmE6nBZrX6S+/0u3V192MrMWNjnHcuHz3FtADm3dSUzAK4eJ1wpxb2LkLluzAg NK5frfPxuK5BRWm9TMbQotHUJfV+3xZMCMDK6LQ7rSImrgJvqRbLmeEkpbj+FG19hTP6 Gy2YHaFBOdZpJomiMpZkkhNnTNkEvcBw25LuA613GR/AgHOtqvL3CNemwYfBZ/oAKe96 71aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AahoEn1X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp4-20020a1709073e0400b00718c7b4cc10si11298818ejc.127.2022.08.01.01.52.30; Mon, 01 Aug 2022 01:52:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@redhat.com header.s=mimecast20190719 header.b=AahoEn1X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230262AbiHAIsL (ORCPT + 99 others); Mon, 1 Aug 2022 04:48:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230195AbiHAIsI (ORCPT ); Mon, 1 Aug 2022 04:48:08 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BEF1432DAC for ; Mon, 1 Aug 2022 01:48:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659343686; 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=BNJ0qfYYXdwgVW9QwtcOifyrJ9WJ2qkCp4TWBgANzYE=; b=AahoEn1XZ9JnroJnLRfg6nJSZ3P/9X2aczutwimpo8M7II/JP/qd8Kia+L5ckOFZMAvRjA vamiz2KCFw6FYmAmmbbzejAL7zxgjmNGFSehQ2/0bHtJ8xTvYQSbv0g+w4bP4AOYZQNau7 h+xPbhSaNcr8/6qDLK9cT80zKUhfEsw= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-180-cAt8bVrIN7ysxq6g8x7UFQ-1; Mon, 01 Aug 2022 04:48:05 -0400 X-MC-Unique: cAt8bVrIN7ysxq6g8x7UFQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8A0B03802B94; Mon, 1 Aug 2022 08:48:04 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BD2972166B26; Mon, 1 Aug 2022 08:48:02 +0000 (UTC) From: Florian Weimer To: "Jason A. Donenfeld" 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 , Linus Torvalds Subject: Re: [PATCH RFC v2] random: implement getrandom() in vDSO References: <20220731013125.2103601-1-Jason@zx2c4.com> Date: Mon, 01 Aug 2022 10:48:01 +0200 In-Reply-To: <20220731013125.2103601-1-Jason@zx2c4.com> (Jason A. Donenfeld's message of "Sun, 31 Jul 2022 03:31:25 +0200") Message-ID: <871qu0qri6.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE 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-kernel@vger.kernel.org * Jason A. Donenfeld: > API-wise, vDSO getrandom has a pair of functions: > > ssize_t getrandom(void *state, void *buffer, size_t len, unsigned int flags); > void *getrandom_alloc([inout] size_t *num, [out] size_t *size_per_each); > > In the first function, the return value and the latter 3 arguments are > the same as ordinary getrandom(), while the first argument is a pointer > to some state allocated with getrandom_alloc(). getrandom_alloc() takes > the desired number of states, and returns an array of states, the number > actually allocated, and the size in bytes of each one, enabling a libc > to use one per thread. We very intentionally do *not* leave state > allocation up to the caller. There are too many weird things that can go > wrong, and it's important that vDSO does not provide too generic of a > mechanism. It's not going to store its state in just any old memory > address. It'll do it only in ones it allocates. I still don't see why this couldn't be per-thread state (if you handle fork generations somehow). I also think it makes sense to introduce batching for the system call implementation first, and tie that to the vDSO acceleration. I expect a large part of the benefit comes from the batching, not the system call avoidance. Thanks, Florian