From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38D9E63B3 for ; Wed, 30 Nov 2022 15:01:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8268AC433D6; Wed, 30 Nov 2022 15:01:47 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="YA6wSyss" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1669820505; 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=BND7rRc9XPDDo7YYi8oruVq6wiGyRDWqN2FS4XKYKhw=; b=YA6wSyss1bZc377olT6x0it7sfwcRYCrtSf2acOgow8kFBZZo2AsBtZkiCkyeTSD2mEE7A Bs64/ew8tY5MzLdjstsh5TnhibrlnpkObbG1UILpDHUUuzD7wm8WDbT51AVtbC23l2N0gf yYFj4mxZzKIEm00fjDdkZ0KwQLsPe9s= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 28efa6da (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 30 Nov 2022 15:01:44 +0000 (UTC) Date: Wed, 30 Nov 2022 15:59:27 +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, linux-api@vger.kernel.org, x86@kernel.org, Greg Kroah-Hartman , Adhemerval Zanella Netto , Carlos O'Donell , Arnd Bergmann , Christian Brauner Subject: Re: [PATCH v10 3/4] random: introduce generic vDSO getrandom() implementation Message-ID: References: <20221129210639.42233-1-Jason@zx2c4.com> <20221129210639.42233-4-Jason@zx2c4.com> <878rjs7mcx.fsf@oldenburg.str.redhat.com> Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Wed, Nov 30, 2022 at 03:51:01PM +0100, Jason A. Donenfeld wrote: > Hi Florian, > > On Wed, Nov 30, 2022 at 11:44:30AM +0100, Florian Weimer wrote: > > * Jason A. Donenfeld: > > > > > diff --git a/include/vdso/datapage.h b/include/vdso/datapage.h > > > index 73eb622e7663..9ae4d76b36c7 100644 > > > --- a/include/vdso/datapage.h > > > +++ b/include/vdso/datapage.h > > > @@ -109,6 +109,16 @@ struct vdso_data { > > > struct arch_vdso_data arch_data; > > > }; > > > > > > +/** > > > + * struct vdso_rng_data - vdso RNG state information > > > + * @generation: a counter representing the number of RNG reseeds > > > + * @is_ready: whether the RNG is initialized > > > + */ > > > +struct vdso_rng_data { > > > + unsigned long generation; > > > + bool is_ready; > > > +}; > > > + > > > > I don't think you can use a type like long here. The header says this: > > > > * vdso_data will be accessed by 64 bit and compat code at the same time > > * so we should be careful before modifying this structure. > > > > So the ABI must be same for 32-bit and 64-bit mode, and long isn't. > > Excellent point. The size of the type needs to be explicit. Will fix. I'll do something like this: diff --git a/include/vdso/datapage.h b/include/vdso/datapage.h index 80e25cdcdb1c..218bbeac5613 100644 --- a/include/vdso/datapage.h +++ b/include/vdso/datapage.h @@ -19,6 +19,19 @@ #include #include +/** + * type vdso_kernel_ulong - unsigned long type that matches kernel's unsigned long + * + * The structs in this file must operate the same way in both 64-bit code and + * in 32-bit compat code, over the same potentially 64-bit kernel. So, this + * type represents the size of an unsigned long as used by kernel-space code. + */ +#ifdef CONFIG_64BIT +typedef u64 vdso_kernel_ulong; +#else +typedef u32 vdso_kernel_ulong; +#endif + #ifdef CONFIG_ARCH_HAS_VDSO_DATA #include #else @@ -115,8 +128,8 @@ struct vdso_data { * @is_ready: signals whether the RNG is initialized */ struct vdso_rng_data { - unsigned long generation; - bool is_ready; + vdso_kernel_ulong generation; + bool is_ready; }; /*