Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp838514rwb; Thu, 19 Jan 2023 03:26:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXusz+kBp+cekOD6Z8nSpyGsJgOcilgWCL5PAcGy9EJOpXPbqLAF5aOqIDuU1eGXuA+rzQCU X-Received: by 2002:a17:906:aed3:b0:84c:9016:79ae with SMTP id me19-20020a170906aed300b0084c901679aemr9837399ejb.53.1674127581243; Thu, 19 Jan 2023 03:26:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674127581; cv=none; d=google.com; s=arc-20160816; b=EzQ6IDyThN1hgZ3/a6vQozFdlJbPHwzvUj/uiEucSm3blw9eiBjs/I6aymY3mZIgr4 XEUkpzn45uYr7K99Z3aNvh39MpuCfdcxwECEAjE4oSFVAZsi/l7jpjzhLOjawwxPCMCt 9YPXw7ibsiJTVKFI5DViBJtnmBC2Cwe1q8nJfy4JDUVs9Ko+J0bw8pZKHdfxvaYhueUv ogdLkY4ppR9qjbIz9Z7LwkRJOGW2zRLmI070guzASm0u5Ma7VUsi612miFfqOKQO8+5q g6n4VLkjL9ECFy9Jj5Ls2Y1LS86MIkK1Sx0ZzZhW+WbJybqiTWAichwlz1a2wBtMO828 7SOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:cc:to:subject:message-id :from:content-transfer-encoding:date:mime-version; bh=RKjLUm1CTJRmIQhsRwnwH8d+tD3SL+97iMhyM3/gsIQ=; b=fMb5V9542Kind5jNNi8Tl4TuKnmVdV0IrMspGgm2OQUvoKssF+ZweqyxEU0634XLCW csvfiZJVdcvOO3iVmNTKlG0x9jpyM3A1o/CDEUT9U2dBoyjVyCnMGVBXYiwxbM8s5CxO 42VKuMbzYCWCD4SEvqV5kL/h4CFN6lJqU+G6RkNAb0L5Tgl5OUiiGuOONHrQF3LHI7Cu JrhpTj4rGvM457RMaWL3ZXXoqqkbzLhWESIcRkOhOmgheUbGLlT+JNZnhL2MDkhGXKVP JVSsWbDk2Abg6WS6MA31UBcWpg+F8fzAnUcE0e7EZ9vr2FXuf1cFFAHTLzNinQQvxBFP inHQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hd9-20020a170907968900b0086a76383bcdsi15775979ejc.130.2023.01.19.03.25.51; Thu, 19 Jan 2023 03:26:21 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229748AbjASLTy convert rfc822-to-8bit (ORCPT + 99 others); Thu, 19 Jan 2023 06:19:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230341AbjASLTo (ORCPT ); Thu, 19 Jan 2023 06:19:44 -0500 Received: from ouvsmtp1.octopuce.fr (ouvsmtp1.octopuce.fr [194.36.166.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2BC16DB13; Thu, 19 Jan 2023 03:19:37 -0800 (PST) Received: from panel.vitry.ouvaton.coop (unknown [194.36.166.20]) by ouvsmtp1.octopuce.fr (Postfix) with ESMTPS id 7E630F7; Thu, 19 Jan 2023 12:19:35 +0100 (CET) Received: from sm.ouvaton.coop (ouvadm.octopuce.fr [194.36.166.2]) by panel.vitry.ouvaton.coop (Postfix) with ESMTPSA id 3554A5E1D6F; Thu, 19 Jan 2023 12:19:35 +0100 (CET) MIME-Version: 1.0 Date: Thu, 19 Jan 2023 11:19:34 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8BIT From: "Yann Droneaud" Message-ID: <954f693d29923cfc538adacddb53acf84d767475@opteya.com> Subject: Re: [RFC PATCH 0/4] random: a simple vDSO mechanism for reseeding userspace CSPRNGs To: "Andy Lutomirski" , "H. Peter Anvin" , "Jason A. Donenfeld" Cc: "Theodore Ts'o" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , "Andy Lutomirski" , "Vincenzo Frascino" , x86@kernel.org, linux-crypto@vger.kernel.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, "Florian Weimer" , "Adhemerval Zanella Netto" , "Carlos O'Donell" In-Reply-To: <15F7D57C-8CC6-4CAE-8B7E-6F480B5F4133@amacapital.net> References: <15F7D57C-8CC6-4CAE-8B7E-6F480B5F4133@amacapital.net> <585ddb35-adc5-f5cf-4db3-27571f394108@zytor.com> X-Originating-IP: 10.0.20.16 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, 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 Hi, 16 janvier 2023 à 20:50 "Andy Lutomirski" a écrit: > > On Jan 13, 2023, at 7:16 PM, H. Peter Anvin wrote: > > On 1/12/23 11:55, Yann Droneaud wrote: > > > 12 janvier 2023 à 18:07 "Jason A. Donenfeld" a écrit: > > > > > > > Sorry Yann, but I'm not interested in this approach, and I don't think > > reviewing the details of it are a good allocation of time. I don't > > want to lock the kernel into having specific reseeding semantics that > > are a contract with userspace, which is what this approach does. > > > > > > > > This patch adds a mean for the kernel to tell userspace: between the > > > last time you call us with getrandom(timestamp,, GRND_TIMESTAMP), > > > something happened that trigger an update to the opaque cookie given > > > to getrandom(timestamp, GRND_TIMESTAMP). When such update happen, > > > userspace is advised to discard buffered random data and retry. > > > The meaning of the timestamp cookie is up to the kernel, and can be > > > changed anytime. Userspace is not expected to read the content of this > > > blob. Userspace only acts on the length returned by getrandom(,, GRND_TIMESTAMP): > > > -1 : not supported > > > 0 : cookie not updated, no need to discard buffered data > > > >0 : cookie updated, userspace should discard buffered data > > > For the cookie, I've used a single u64, but two u64 could be a better start, > > > providing room for implementing improved behavior in future kernel versions. > > > > > > > Please just let me iterate on my original patchset for a little bit, > > without adding more junk to the already overly large conversation. > > > > > > > > I like the simplicity of my so called "junk". It's streamlined, doesn't > > > require a new syscall, doesn't require a new copy of ChaCha20 code. > > > I'm sorry it doesn't fit your expectations. > > > > > > > > > Why would anything more than a 64-bit counter be ever necessary? It only needs to be incremented. > > > > This is completely broken with CRIU or, for that matter, with VM forking. > Which raise the question of the support of CRIU with Jason's vDSO proposal. AFAIK CRIU handle vDSO[1] by interposing symbols so that, on restore, the process will call the interposed functions, which will resolve the new vDSO's functions. vgetrandom_alloc() would have been called before the checkpoint, allocating one opaque state of size x. After the restore, the vDSO's getrandom() would be given this opaque state, expecting it having size y. As the content of the opaque state should have been cleared per MADV_WIPEONFORK, there's nothing in the state that could help vDSO's getrandom() to achieve backward compatibility. I think backward compatibility can be achieved by adding an opaque state size argument to vDSO's getrandom(). What to think Jason ? [1] https://criu.org/Vdso Regards. -- Yann Droneaud OPTEYA