From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Aleksa Sarai <cyphar@cyphar.com>,
linux-kernel@vger.kernel.org, patches@lists.linux.dev,
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>,
Florian Weimer <fweimer@redhat.com>,
Arnd Bergmann <arnd@arndb.de>, Jann Horn <jannh@google.com>,
Christian Brauner <brauner@kernel.org>,
David Hildenbrand <dhildenb@redhat.com>
Subject: Re: [PATCH v18 2/5] random: add vgetrandom_alloc() syscall
Date: Fri, 28 Jun 2024 16:09:01 +0200 [thread overview]
Message-ID: <Zn7D_YBC2SXTa_jX@zx2c4.com> (raw)
In-Reply-To: <87v81txjb7.ffs@tglx>
On Fri, Jun 28, 2024 at 03:56:12PM +0200, Thomas Gleixner wrote:
> Jason!
>
> On Thu, Jun 20 2024 at 14:18, Jason A. Donenfeld wrote:
> > On Wed, Jun 19, 2024 at 07:13:26PM -0700, Aleksa Sarai wrote:
> >> Then again, I guess since libc is planned to be the primary user,
> >> creating a new syscall in a decade if necessary is probably not that big
> >> of an issue.
> >
> > I'm not sure going the whole big struct thing is really necessary, and
> > for an additional reason: this is only meant to be used with the vDSO
> > function, which is also coupled with the kernel. It doesn't return
> > information that's made to be used (or allowed to be used) anywhere
> > else. So both the vdso code and the syscall code are part of the same
> > basic thing that will evolve together. So I'm not convinced extensible
> > struct really makes sense for this, as neat as it is.
> >
> > If there's wide consensus that it's desirable, in contrast to what I'm
> > saying, I'm not vehemently opposed to it and could do it, but it just
> > seems like massive overkill and not at all necessary. Things are
> > intentionally as simple and straightforward as can be.
>
> Right, but the problem is that this is a syscall, so people are free to
> explore it even without the vdso part. Now when you want to change it
> later then you are caught in the no-regression trap.
>
> So making it extensible with backwards compability in place (add the
> unused flag field and check for 0) will allow you to expand without
> breaking users.
Okay, so it sounds like you're also in camp-struct. I guess let's do it
then. This opens up a few questions, but I think we can get them sorted.
Right now this version of the patch has this signature:
void *vgetrandom_alloc(unsigned int *num, unsigned int *size_per_each,
unsigned long addr, unsigned int flags);
The semantics are currently:
- [in] unsigned int num - desired number of states
- [in] unsigned long addr - reserved, nothing
- [in] unsigned int flags - reserved, nothing
- [out] unsigned int num - actual number of states
- [out] unsigned int size_per_each - size of each state
- [out] void* return value - the allocated thing
Following Aleksa's suggestion, we keep the `[out] void* return value` as
a return value, but move all the other into a struct:
void *vgetrandom_alloc(struct vgetrandom_args *arg, size_t size);
So now the struct can become:
struct vgetrandom_args {
[in] u64 flags;
[in/out] u32 num;
[out] u32 size_per_each;
}
Alternatively, this now opens the possibility to incorporate Eric's
suggestion of also returning the number of allocated bytes, which is
perhaps definitely to deal with, but I didn't do because I wanted
symmetry in the argument list. So doing that, now we have:
struct vgetrandom_args {
[in] u64 flags;
[in/out] u32 num;
[out] u32 size_per_each;
[out] u64 bytes_allocated;
}
Does that seem reasonable? There's a little bit of mixing of ins and
outs within the struct, and the return value is still a return value,
rather than a `[out] void *ret` inside of the struct. But maybe that's
fine. Also I used u32 there for the two smaller arguments, but maybe
that's silly and we should go straight to u64?
Anyway, how does that look to you?
Jason
next prev parent reply other threads:[~2024-06-28 14:09 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-20 0:53 [PATCH v18 0/5] implement getrandom() in vDSO Jason A. Donenfeld
2024-06-20 0:53 ` [PATCH v18 1/5] mm: add VM_DROPPABLE for designating always lazily freeable mappings Jason A. Donenfeld
2024-06-20 0:53 ` [PATCH v18 2/5] random: add vgetrandom_alloc() syscall Jason A. Donenfeld
2024-06-20 2:13 ` Aleksa Sarai
2024-06-20 12:18 ` Jason A. Donenfeld
2024-06-28 13:56 ` Thomas Gleixner
2024-06-28 14:09 ` Jason A. Donenfeld [this message]
2024-06-28 14:11 ` Jason A. Donenfeld
2024-07-01 11:53 ` Jason A. Donenfeld
2024-07-01 13:59 ` Jason A. Donenfeld
2024-06-20 0:53 ` [PATCH v18 3/5] arch: allocate vgetrandom_alloc() syscall number Jason A. Donenfeld
2024-06-20 0:53 ` [PATCH v18 4/5] random: introduce generic vDSO getrandom() implementation Jason A. Donenfeld
2024-06-28 13:57 ` Thomas Gleixner
2024-06-20 0:53 ` [PATCH v18 5/5] x86: vdso: Wire up getrandom() vDSO implementation Jason A. Donenfeld
2024-06-28 13:57 ` Thomas Gleixner
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=Zn7D_YBC2SXTa_jX@zx2c4.com \
--to=jason@zx2c4.com \
--cc=adhemerval.zanella@linaro.org \
--cc=arnd@arndb.de \
--cc=brauner@kernel.org \
--cc=carlos@redhat.com \
--cc=cyphar@cyphar.com \
--cc=dhildenb@redhat.com \
--cc=fweimer@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=jannh@google.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox