Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp9147499rwb; Thu, 24 Nov 2022 08:40:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf5e4qItGpE5wl3ffyoZN3d+LCU/qsS4bKGI5vXhlPeNBPk13aUAiJgXRba9YeMDg8Et3UeJ X-Received: by 2002:aa7:d5c5:0:b0:46a:1d7:c94d with SMTP id d5-20020aa7d5c5000000b0046a01d7c94dmr10601720eds.327.1669308010414; Thu, 24 Nov 2022 08:40:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669308010; cv=none; d=google.com; s=arc-20160816; b=jz+UMu8uuc82uUYGEpPD4KRyqKGtsVXKQ5zp0Vg1g/epH4Q3s5DYXyQQWLx5+g5vpz EtBtPRvpNBa99brF5R1DLA2ncKH1AACWvIoxaUtCdeSI7goPo8qfQn2leAns033NSezc qIPCUpFSHtwj/TxU6GlzJCmDYsOmVa9pHAQrGE1yI39xo/c0ascE5z7BLpqZLX5Y51r/ GgYr4UOn9IUA5kg4BbAM5GxgPVqI0uPDUhcer/kbiI+Lt6kYTqX1q7L/gtsLFmgE5geb IPbh7IrfZTo0URPeAvSICmZbdZ0SErP6zIfVoIgq1Z0H/I1kVfBkAkG1mLxaBtFsvDQL yhCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=EzDoEvNDhRphmuoSNKNVxLbek8oLLix/b9dbHW5QtLs=; b=d/NYPnzVoSYNGCVQ0MWsdQ9Yjaf23QVJtBZcZN35nr9NcJ30z3O6j4R511NHTZOVPb rUhTlcdcbYRiSkFhLR9gTsXqsLaNGNDi0hYKotE+0eZW8h1JuVyO3Pz5nnfwLAo0gbCk 701pImA3b4iynL5aHOrT27ovjfNO6RKg6SpxHAj4A+AkfvRRwmpG3Utx3j7g4znLSnRS ZBtuoRYHKL/K5glDzBsrMct04UeirUqgzOvnH22SAeDXkvezAwhsr4DUkVxOWIKKpZF0 VJMlMgMO/e/aDTa9qUL9PfESVLG5BkmgxrHrLLXRckmDlCG/Y9HVmxTPqmdB5Z14v4XH W+mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=GLM0uBfm; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ec26-20020a0564020d5a00b0045928479b71si1346598edb.405.2022.11.24.08.39.39; Thu, 24 Nov 2022 08:40:10 -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=@zx2c4.com header.s=20210105 header.b=GLM0uBfm; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229535AbiKXQan (ORCPT + 99 others); Thu, 24 Nov 2022 11:30:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbiKXQal (ORCPT ); Thu, 24 Nov 2022 11:30:41 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EDE216FB29; Thu, 24 Nov 2022 08:30:40 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D3DFFB8287B; Thu, 24 Nov 2022 16:30:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45C35C433C1; Thu, 24 Nov 2022 16:30:36 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="GLM0uBfm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1669307434; 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=EzDoEvNDhRphmuoSNKNVxLbek8oLLix/b9dbHW5QtLs=; b=GLM0uBfmyJutlyfrCPqlI3ap4XE52yP7cYHnWXQLh83VEssdyMGcsqspkq6b8Tu9mdbQIO NwcVzP3GcuZ128HU52dJhFTjUij1LmkBMFTeSyk0FIaPs6JJA1lzBDbaLwpFa/R/9M/rxK FH6gc0vEUWPKCBVX2XMy5Q1IkLY5vo4= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id a4fe9579 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 24 Nov 2022 16:30:33 +0000 (UTC) Date: Thu, 24 Nov 2022 17:30:28 +0100 From: "Jason A. Donenfeld" To: Florian Weimer Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, tglx@linutronix.de, linux-crypto@vger.kernel.org, x86@kernel.org, Greg Kroah-Hartman , Adhemerval Zanella Netto , Carlos O'Donell , linux-api@vger.kernel.org Subject: Re: [PATCH v6 1/3] random: add vgetrandom_alloc() syscall Message-ID: References: <20221121152909.3414096-1-Jason@zx2c4.com> <20221121152909.3414096-2-Jason@zx2c4.com> <87v8n6lzh9.fsf@oldenburg.str.redhat.com> <87a64g7wks.fsf@oldenburg.str.redhat.com> <87cz9c5z1f.fsf@oldenburg.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,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 On Thu, Nov 24, 2022 at 01:24:42PM +0100, Jason A. Donenfeld wrote: > Hi Florian, > > On Thu, Nov 24, 2022 at 01:15:24PM +0100, Florian Weimer wrote: > > * Jason A. Donenfeld: > > > > > Hi Florian, > > > > > > On Thu, Nov 24, 2022 at 06:25:39AM +0100, Florian Weimer wrote: > > >> * Jason A. Donenfeld: > > >> > > >> > Hi Florian, > > >> > > > >> > On Wed, Nov 23, 2022 at 11:46:58AM +0100, Florian Weimer wrote: > > >> >> * Jason A. Donenfeld: > > >> >> > > >> >> > + * The vgetrandom() function in userspace requires an opaque state, which this > > >> >> > + * function provides to userspace, by mapping a certain number of special pages > > >> >> > + * into the calling process. It takes a hint as to the number of opaque states > > >> >> > + * desired, and returns the number of opaque states actually allocated, the > > >> >> > + * size of each one in bytes, and the address of the first state. > > >> >> > + */ > > >> >> > +SYSCALL_DEFINE3(vgetrandom_alloc, unsigned long __user *, num, > > >> >> > + unsigned long __user *, size_per_each, unsigned int, flags) > > >> >> > > >> >> I think you should make this __u64, so that you get a consistent > > >> >> userspace interface on all architectures, without the need for compat > > >> >> system calls. > > >> > > > >> > That would be quite unconventional. Most syscalls that take lengths do > > >> > so with the native register size (`unsigned long`, `size_t`), rather > > >> > than u64. If you can point to a recent trend away from this by > > >> > indicating some commits that added new syscalls with u64, I'd be happy > > >> > to be shown otherwise. But AFAIK, that's not the way it's done. > > >> > > >> See clone3 and struct clone_args. > > > > > > The struct is one thing. But actually, clone3 takes a `size_t`: > > > > > > SYSCALL_DEFINE2(clone3, struct clone_args __user *, uargs, size_t, size) > > > > > > I take from this that I too should use `size_t` rather than `unsigned > > > long.` And it doesn't seem like there's any compat clone3. > > > > But vgetrandom_alloc does not use unsigned long, but unsigned long *. > > You need to look at the contents for struct clone_args for comparison. > > The other direction would be making this a u32 I think `unsigned int` is actually a sensible size for what these values should be. That eliminates the problem and potential bikeshed too. So I'll go with that for v+1. Jason