All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: Florian Weimer <fweimer@redhat.com>
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 <gregkh@linuxfoundation.org>,
	Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
	Carlos O'Donell <carlos@redhat.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Christian Brauner <brauner@kernel.org>
Subject: Re: [PATCH v10 3/4] random: introduce generic vDSO getrandom() implementation
Date: Wed, 30 Nov 2022 15:59:27 +0100	[thread overview]
Message-ID: <Y4dvz4d0dpFzJZ9L@zx2c4.com> (raw)
In-Reply-To: <Y4dt1dLZMmogRlKa@zx2c4.com>

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 <vdso/time32.h>
 #include <vdso/time64.h>

+/**
+ * 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 <asm/vdso/data.h>
 #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;
 };

 /*


  reply	other threads:[~2022-11-30 15:02 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-29 21:06 [PATCH v10 0/4] implement getrandom() in vDSO Jason A. Donenfeld
2022-11-29 21:06 ` [PATCH v10 1/4] random: add vgetrandom_alloc() syscall Jason A. Donenfeld
2022-11-29 22:02   ` Thomas Gleixner
2022-11-30  0:59     ` Jason A. Donenfeld
2022-11-30  1:37       ` Thomas Gleixner
2022-11-30  1:42         ` Jason A. Donenfeld
2022-11-30 22:39     ` David Laight
2022-12-01  0:14       ` Jason A. Donenfeld
2022-11-30 10:51   ` Florian Weimer
2022-11-30 15:39     ` Jason A. Donenfeld
2022-11-30 16:38       ` Jason A. Donenfeld
2022-12-02 14:38         ` Jason A. Donenfeld
2022-12-01  2:16       ` Jason A. Donenfeld
2022-12-02 17:17       ` Florian Weimer
2022-12-02 18:29         ` Jason A. Donenfeld
2022-11-29 21:06 ` [PATCH v10 2/4] arch: allocate vgetrandom_alloc() syscall number Jason A. Donenfeld
2022-11-30  8:56   ` Geert Uytterhoeven
2022-11-30 10:06     ` Jason A. Donenfeld
2022-11-30 10:51       ` Arnd Bergmann
2022-11-29 21:06 ` [PATCH v10 3/4] random: introduce generic vDSO getrandom() implementation Jason A. Donenfeld
2022-11-29 22:42   ` Thomas Gleixner
2022-11-30  1:09     ` Jason A. Donenfeld
2022-11-30 10:44   ` Florian Weimer
2022-11-30 14:51     ` Jason A. Donenfeld
2022-11-30 14:59       ` Jason A. Donenfeld [this message]
2022-11-30 15:07         ` Arnd Bergmann
2022-11-30 15:12           ` Jason A. Donenfeld
2022-11-30 15:29             ` Arnd Bergmann
2022-11-30 15:47               ` Jason A. Donenfeld
2022-11-30 16:13                 ` Arnd Bergmann
2022-11-30 16:40                   ` Jason A. Donenfeld
2022-11-30 17:00                 ` Thomas Gleixner
2022-11-29 21:06 ` [PATCH v10 4/4] x86: vdso: Wire up getrandom() vDSO implementation Jason A. Donenfeld
2022-11-29 22:52   ` Thomas Gleixner
2022-11-30  1:11     ` Jason A. Donenfeld
2022-11-30  5:22   ` Eric Biggers
2022-11-30 10:12     ` Jason A. Donenfeld

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y4dvz4d0dpFzJZ9L@zx2c4.com \
    --to=jason@zx2c4.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=arnd@arndb.de \
    --cc=brauner@kernel.org \
    --cc=carlos@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.