Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2139392imn; Mon, 1 Aug 2022 12:37:53 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uuI2i/n+xlM0zwyTHBBgZbJ7yS00d8+qo6U4DiNwMTZLt4sz6tDTdyV4zg0YtCBcLj6nYY X-Received: by 2002:a17:907:2855:b0:72b:67b7:2c28 with SMTP id el21-20020a170907285500b0072b67b72c28mr14103623ejc.331.1659382673693; Mon, 01 Aug 2022 12:37:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659382673; cv=none; d=google.com; s=arc-20160816; b=KNTosz7po2B+IUtNPsSkeLl7UZQV5AgTDca1jIJpIBfZ81Bvb3OWlb8pOY1a31PBSq 5f2CZCYSklBzyAWRg8+jCE/KE2P9Ol91VslBfABrVGE6I6/f+jKfIfR2yNRzwZvAT5jB nkZfEFzs5ClCbi0Cnn7EWZshyh7YpkAcR7NqZ6o04KfP49ugorfKRzZV8DWqkmSX6G0L klXuEiLxe8GCTUCHSmPNJu5zEW+kQhPShBXRuNNnV5TwFMamod3mFiPddlbDugym6xVb cB+eflQCbHPRAmsMoJgBd2d5SwX8/bNpAJ75hJ2VDIpDOmPTS1mir06FntY8dOOR8xLf W6Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=YCVoqN35XPquvGhrCezKkn75+pkhWZjm/1Cnh7Cbjjk=; b=yLsSHPO5MgNs9nucCeiPht6Wlt5MQHMl2Cz47cTyHKlw1p9/BTyCYNzEaXv8Rr86qS 6caKd76mqODls5f7Sp/bJRCETzNOnBZqP8xxgruyzChrPUYVhYRleN6GU/CWv5aF/Bhg 86e3NQWO95/FW6rR9GHhxJgtJiCEMKMZjlXTthLyiSkWTCQztdZvhjiJm3dUztUBQ5TH U75nXT8Bw7iwTTN1OjkAYOubUXsk0OOpyYq/VE28/Khe/rV1qTWKIwg4li8iQK7B8A6p 7OgT5vCUa8rEphgND8cKP8SHNF8YsuYFiQzduCpQbUES7Nqr8d+q23XdT5hcqaheCLCR suVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=RjzhuQx5; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i14-20020a05640242ce00b0043a72c8b750si1041795edc.114.2022.08.01.12.36.56; Mon, 01 Aug 2022 12:37:53 -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=@linutronix.de header.s=2020 header.b=RjzhuQx5; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231364AbiHATbi (ORCPT + 99 others); Mon, 1 Aug 2022 15:31:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234725AbiHATaj (ORCPT ); Mon, 1 Aug 2022 15:30:39 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFAD965FC; Mon, 1 Aug 2022 12:30:24 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1659382221; 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=YCVoqN35XPquvGhrCezKkn75+pkhWZjm/1Cnh7Cbjjk=; b=RjzhuQx5633QszrkNIxKCT7aAaRPPXzemzaBIwOMjfX2YZabgHe/r7Lguz6d1Is3f44Ax3 LKd8mdnTv3nd8Aqvh4iJuabq6cmCskzkUuoemqTUyFXoA1TknueoyXvAir9PZRFCBb2HXY bzcy+DznOEC+TxuOUcLQJBamQ0CAFNhawScxdqrSLfG2bdzyRRXNtNdaAns24oT6uSr2Vm CAuavR5mlznGm/hWtDda4jaD07/0KaPavXRiU56zbrsmbkgfHCZj2m8svTPCtS4r7nH/Wz rkwxVLRRY3MTB1j7GCNGoMezUw1fJFB95i9IaAR3nNA4bxwgvVY/9A3hYjewCA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1659382221; 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=YCVoqN35XPquvGhrCezKkn75+pkhWZjm/1Cnh7Cbjjk=; b=k6boVoGAAXOxRdWveTovBjKjjH+yIoMo1MbINTIwy3XYuV1UdsYLRMTliJs4KGtWBR2jR+ mu8eRVGKS6DnspAQ== To: "Jason A. Donenfeld" , 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 In-Reply-To: References: <20220729145525.1729066-1-Jason@zx2c4.com> Date: Mon, 01 Aug 2022 21:30:20 +0200 Message-ID: <87zggnsqwj.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 Jason! On Sun, Jul 31 2022 at 01:45, Jason A. Donenfeld wrote: > Thanks a bunch for chiming in. Indeed this whole thing is kind of crazy, > so your input is particularly useful here. > > On Sat, Jul 30, 2022 at 08:48:42AM -0700, Linus Torvalds wrote: >> It's just too specialized, and the people who care about performance >> can - and do - do special things anyway. > > To be clear, I really would rather not do this. I'm not really looking > for more stuff to do, and I don't tend to write (public) code "just > 'cuz". My worry is that by /not/ doing it, footguns will proliferate. > The glibc thing was what finally motivated me to want to at least sketch > out a potential action to make this kind of (apparently common) urge of > writing a userspace RNG safer. But the user space tinkering will continue no matter what. They might then just use the vdso to get access to the ready/generation bits. I've seen "better" VDSO implementations to access time. :) > 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); I'm not seeing any reason to have those functions at all. The only thing which would be VDSO worthy here is the access to random_state->ready and random_state->generation as that's the information which is otherwise not available to userspace. So you can just have: int random_check_and_update_generation(u64 *generation); Everything else is library material, really. Thanks, tglx