Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp1434360rwb; Fri, 5 Aug 2022 01:39:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR6pq3v8rwNgVPIDD/EV7PtzpaPctCsSKDV5wXVlxWym3Ww2H6o9YGN0aDuaHUdZa/PoGz+s X-Received: by 2002:a17:90b:198d:b0:1f3:f72:cfdc with SMTP id mv13-20020a17090b198d00b001f30f72cfdcmr15011813pjb.237.1659688760606; Fri, 05 Aug 2022 01:39:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659688760; cv=none; d=google.com; s=arc-20160816; b=aEXYYK522nwq7sc4SVjPN50h+fS71apGwVsgIIy5GgrsEdqZoixRjr/qvL0lHQiaRd 4SmhRCvHWZiW/9DcXTSq24t2jIeC5k8ulxboqO1IozadibHsMbwL0qklT59g/njxpmeL PYK6QnBwwxX7fxEGI/0Uxc2UtEpGSul54+ShlwoGPDAiXJaMhyFNw9gGLWgDqS5MIy3z ELjove/Y5KF3+mSpsJDcR5VkbT/1Ly5wwAnmnRmMcIOIULgWIWk1IRAV3/1wXZLGa5Tx 3oTbM8DuvVyAse6D2B+gYuwNTq6hdAwhI59bqZymtqahQrruUmpxcgs7woZcyzT1U/hi yxCA== 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=qWEEAO6UGfW/YnjBP9VOyZB3NA9ALsAqziwzeAGrxtU=; b=BJDRGv5gQsEgmriBjDTDbZRt2jiwE90FLu3NI7lk9O6UJSILpAS1Go0MGX4PH6M4gl aXaOGehma6SExMw2Hw+X5rNE06nXkHl/S171d7bcNF0BzEKVC6RIhHwKqUYCecWQ+LEC 7VX6wkwBQslsvZbCiDAJUyJ1yz8yVHvujFaqrnYwt4+xn8iaDlSFqUXbAbsl5sRvHpvH lpgfdl/VUZS8DX+xc6Uf0pVTyg7z3l+9tBF+JxvwKEhE26enal6+3g5oOH/dGLVahPg2 u4DMPCr7FEBQ25eOXHSuoJwlWCTShModBLlCzoKVOrPi73SeMFL6BXEJ32AvaYFchD3u Haiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VyO+bjXz; 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 x189-20020a6386c6000000b0041c2c286030si2679959pgd.218.2022.08.05.01.39.06; Fri, 05 Aug 2022 01:39:20 -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=VyO+bjXz; 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 S236091AbiHEIgb (ORCPT + 99 others); Fri, 5 Aug 2022 04:36:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234451AbiHEIg1 (ORCPT ); Fri, 5 Aug 2022 04:36:27 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B4AC618F for ; Fri, 5 Aug 2022 01:36:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659688585; 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=qWEEAO6UGfW/YnjBP9VOyZB3NA9ALsAqziwzeAGrxtU=; b=VyO+bjXz4uCDBI8zo8Y8JTgHDMos9n92/f7xTm8n/0oWLrwEqihCEdGilfczEqviz97WIM y6+Lu143cxIPTjyDs699czqJBzSv213xPXGxy9b9A5i1Tx6nJ1lOiD5tz5tmhIAMv/2+z/ ZqwgshXZMp+J4hbSAbABnT0kKHMHkuk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-661-gQzcc_3NN-a-RNHlJCBRag-1; Fri, 05 Aug 2022 04:36:21 -0400 X-MC-Unique: gQzcc_3NN-a-RNHlJCBRag-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EAFDD1019C91; Fri, 5 Aug 2022 08:36:20 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.51]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5303F492C3B; Fri, 5 Aug 2022 08:36:18 +0000 (UTC) From: Florian Weimer To: Thomas Gleixner Cc: "Jason A. Donenfeld" , Linus Torvalds , 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 Subject: Re: [PATCH RFC v1] random: implement getrandom() in vDSO References: <20220729145525.1729066-1-Jason@zx2c4.com> <87zggnsqwj.ffs@tglx> <87bkt2sqq4.ffs@tglx> <878ro6smmm.ffs@tglx> Date: Fri, 05 Aug 2022 10:36:16 +0200 In-Reply-To: <878ro6smmm.ffs@tglx> (Thomas Gleixner's message of "Tue, 02 Aug 2022 17:14:57 +0200") Message-ID: <87v8r713zz.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.85 on 10.11.54.10 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 * Thomas Gleixner: > On Tue, Aug 02 2022 at 15:59, Jason A. Donenfeld wrote: >> On Tue, Aug 02, 2022 at 03:46:27PM +0200, Thomas Gleixner wrote: >>> Right now the Linux VDSO functions are 1:1 replacements for system calls >>> and not adding a magic pile of functionality which is otherwise not >>> available. >>> >>> What you are proposing is to have an implementation which is not >>> available via a regular syscall. Which means you are creating a VDSO >>> only syscall which still has the same problem as any other syscall in >>> terms of API design and functionality which needs to be supported >>> forever. >> >> Wait, what? That's not correct. The WHOLE point is that vdso getrandom() >> will generate bytes in the same way as the ordinary syscall, without >> differences. Same function name, same algorithm. But just faster, >> because vDSO. I explicitly don't want to dip into introducing something >> different. That's the big selling point: that vDSO getrandom() and >> syscall getrandom() are the same thing. If you trust one, you can trust >> the other. If you expect properties of one, you get that from the other. >> If you know the API of one, you can use the other. > > Seriously no. All existing VDSO functions have exactly the same function > signature and semantics as their syscall counterparts. So they are drop > in equivalent. > > But: > > ssize_t getrandom(void *, void *, size_t, unsigned int); > > is very much different than > > ssize_t getrandom(void *, size_t, unsigned int); > > Different signature and different semantics. Just use ssize_t getrandom(size_t, unsigned int, void *); then and have the system call ignore the argument. There is recent precedent for adding additional arguments to system calls, see membarrier. If we want to be super-conservative, we could add a new flag and have the vDSO version always call into the kernel if the flag isn't set. *This* part is far less problematic compared to the approach to per-thread memory allocation. We now have: * Explicit donation of memory areas to the kernel (set_robust_list, rseq). * This getrandom_alloc vDSO call which does something unspecified and may return pointers which are or are not abstract. (How is CRIU expected to handle this?) * There's also userspace shadow stack coming. I think the kernel moved away from implicit allocation, to something mmap-based. It's not clear to me why that would be okay here, but not for shadow stacks. Does io_uring have to handle a similar problem, too? As long as the vDSO doesn't use private system calls, I don't expect any practical problems, but this optimization doesn't really look to me like something that intrinsically benefits from a completely new way of allocating userspace memory for use by the kernel. Thanks, Florian