Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5997827rwl; Mon, 9 Jan 2023 02:50:55 -0800 (PST) X-Google-Smtp-Source: AMrXdXuMJiTKl+0DZddRW9DI4MMmB/2JhSJina79WZs4GRPI9bkWSajmxLY8WJnYCy5tBpD4scJa X-Received: by 2002:a17:903:2685:b0:192:bd33:7b59 with SMTP id jf5-20020a170903268500b00192bd337b59mr29391114plb.61.1673261455756; Mon, 09 Jan 2023 02:50:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673261455; cv=none; d=google.com; s=arc-20160816; b=ejLPMCvHSqVJqAhrM3gz8cg7Z6a0XayXAiVt3uPbKnBjIkfzxiVJWl4MxZf1dfWfuM J6FlSuCBWuXip+wiUZeP+//DidGLUyBwdcK2R7xU1iPClu6UIsxnPBOwvumpas4UTc51 g0aTnIH1qh5SNUgHqPfslzjpmZcChDgmDQE7bGqwWnpqM4XytVGxghkkQUDRa4Tnnszn s1VqxlZ6uEFE4fuRkwzMGDKK+bduHcnHcUoKKM5Pe4P9Oxw6vFThFShEIIIK8iFMD6cW V/zj+hlgJWmUQlc1aT7diXGrEOoAZqnmgP6+XlDN5Jg/Fo8iTmxysuUsfFXV7bbkHED/ k7Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:message-id:in-reply-to:date:references:subject:cc:to :from:dkim-signature; bh=Gp01bbHImBb9jQ++aTa7ksC+hJELx0J0kuwwfn5XG7k=; b=MxWc6gqHkMcuuOPeH9/+cO0ORC4UNulqSIv8HTE2XJP1SxiiMmYDCfyxhHnAfGl0z5 YKLsP5oHZSBqvWlqPkOa1itqpQuDpPCVYnDLtaR+J4wpmUqoH61Mzk1AUV7igSroas/o bcMinMa/iOXqUJTDf7AjnQQ4T0Dkitt/EbS/zZac9p6fh+AaviLRDK5uDwPw21sn3TPS wZhwG5jSZMnR6cKRrAp2jFyyoOE9w/A6/a0eltZBEvEiLSFxSWRZDEEDLRCUncKhU3q/ ukTPzuQPNnkaAQqA5ywHoxUstmQot8yymGbgaczchOO+sOBs8u9O18o8tYqvPdviKFk5 yyTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aG1t4uu1; 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=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 m27-20020a634c5b000000b00473d2108701si9372107pgl.198.2023.01.09.02.50.37; Mon, 09 Jan 2023 02:50:55 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aG1t4uu1; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236900AbjAIKlz (ORCPT + 99 others); Mon, 9 Jan 2023 05:41:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237105AbjAIKlr (ORCPT ); Mon, 9 Jan 2023 05:41:47 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 838A1186F0 for ; Mon, 9 Jan 2023 02:34:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673260457; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Gp01bbHImBb9jQ++aTa7ksC+hJELx0J0kuwwfn5XG7k=; b=aG1t4uu1Ul8qF9mja9Rr9MI8vtaCYNTato74bCIajzqOn8Q7g8cVnebwd80XiDCNUkWX60 4uKF6Aius0150PiuWHNoQrFVuaA4sMTywMaqeVWaIyx3wblMcZsVRQeLHd6JVPstxa/rl1 DBGA6SLnM4xahEIovXl8QYzwzb3cdQk= 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-192-6lJLLzdVMhu3P5ythx0hnw-1; Mon, 09 Jan 2023 05:34:14 -0500 X-MC-Unique: 6lJLLzdVMhu3P5ythx0hnw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E9F9E1C09044; Mon, 9 Jan 2023 10:34:13 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 08EA240C2064; Mon, 9 Jan 2023 10:34:10 +0000 (UTC) From: Florian Weimer To: Linus Torvalds Cc: "Jason A. Donenfeld" , Andy Lutomirski , Ingo Molnar , 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" , Arnd Bergmann , Jann Horn , Christian Brauner , linux-mm@kvack.org, mlichvar@redhat.com Subject: Re: [PATCH v14 2/7] mm: add VM_DROPPABLE for designating always lazily freeable mappings References: <20230101162910.710293-1-Jason@zx2c4.com> <20230101162910.710293-3-Jason@zx2c4.com> Date: Mon, 09 Jan 2023 11:34:09 +0100 In-Reply-To: (Linus Torvalds's message of "Tue, 3 Jan 2023 11:54:35 -0800") Message-ID: <874jt0kndq.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,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-crypto@vger.kernel.org * Linus Torvalds: > On Tue, Jan 3, 2023 at 11:35 AM Jason A. Donenfeld wrot= e: >> >> I don't think this is about micro-optimization. Rather, userspace RNGs >> aren't really possible in a safe way at the moment. > > "Bah, humbug", to quote a modern-time philosopher. > > It's humbug simply because it makes two assumptions that aren't even vali= d: > > (a) that you have to do it in user space in the first place > > (b) that you care about the particular semantics that you are looking for > > The thing is, you can just do getrandom(). It's what people already > do. Problem solved. We are currently doing this in glibc for our arc4random implementation, after Jason opposed userspace buffering. If chrony is recompiled against the glibc version of arc4random (instead of its OpenBSD compat version, which uses userspace buffering), the result is a 25% drop in NTP packet response rate: | The new arc4random using getrandom() seems to have a significant | impact on performance of chronyd operating as an NTP server. On an | Intel E3-1220 CPU, I see that the maximum number of requests per | second dropped by about 25%. That would be an issue for some public | NTP servers. arc4random is too slow This is *not* =E2=80=9Carc4random is 25% slower=E2=80=9D, it is the measure= d overall impact on server performance. Historically, the solution space for getrandom and arc4random are slightly different. The backronym is =E2=80=9CA Replacement Call For rando= m=E2=80=9D, i.e., you should be able to use arc4random without worrying about performance. I don't expect cryptographic libraries to turn to arc4random to implement their random number generators, and that programmers that use low-level OpenSSL primitives (for example) keep calling RAND_bytes instead of arc4random because it is available to them. We did these changes on the glibc side because Jason sounded very confident that he's able to deliver vDSO acceleration for getrandom. If that fails to materialize, we'll just have to add back userspace buffering in glibc. At least we can get process fork protection via MADV_WIPEONFORK, solving a real problem with the usual arc4random compat implementation. (The OpenBSD mechanism for this is slightly different.) We won't get VM fork protection or forward secrecy against ptrace. But the latter is rather speculative anyway because if you can do ptrace once, you can likely do ptrace twice, the first time patching the process to remove forward secrecy. There is a real gap for VM forks, but I'm not sure how much that matters in practice. Live migration has to be implemented in such a way that this isn't observable (otherwise TCP connections etc. would break), and long-term keys probably shouldn't be generated under virtualization anyway. Thanks, Florian