From: Thomas Gleixner <tglx@linutronix.de>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>,
linux-kernel@vger.kernel.org, patches@lists.linux.dev
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>,
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>,
Christian Brauner <brauner@kernel.org>
Subject: Re: [PATCH v10 1/4] random: add vgetrandom_alloc() syscall
Date: Tue, 29 Nov 2022 23:02:29 +0100 [thread overview]
Message-ID: <87cz95v2q2.ffs@tglx> (raw)
In-Reply-To: <20221129210639.42233-2-Jason@zx2c4.com>
Jason!
On Tue, Nov 29 2022 at 22:06, Jason A. Donenfeld wrote:
> +
> +/********************************************************************
> + *
> + * vDSO support helpers.
> + *
> + * The actual vDSO function is defined over in lib/vdso/getrandom.c,
> + * but this section contains the kernel-mode helpers to support that.
> + *
> + ********************************************************************/
> +
> +#ifdef CONFIG_VGETRANDOM_ALLOC_SYSCALL
> +/**
> + * vgetrandom_alloc - allocate opaque states for use with vDSO getrandom().
> + *
> + * @num: on input, a pointer to a suggested hint of how many states to
> + * allocate, and on output the number of states actually allocated.
> + *
> + * @size_per_each: the size of each state allocated, so that the caller can
> + * split up the returned allocation into individual states.
> + *
> + * @flags: currently always zero.
NIT!
I personally prefer and ask for it in stuff I maintain:
* @num: On input, a pointer to a suggested hint of how many states to
* allocate, and on output the number of states actually allocated.
*
* @size_per_each: The size of each state allocated, so that the caller can
* split up the returned allocation into individual states.
*
* @flags: Currently always zero.
But your turf :)
> + *
> + * The getrandom() vDSO function in userspace requires an opaque state, which
> + * this function allocates 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 provides the caller with the number of opaque states actually
> + * allocated, the size of each one in bytes, and the address of the first
> + * state.
make W=1 rightfully complains about:
> +
drivers/char/random.c:182: warning: bad line:
> + * Returns a pointer to the first state in the allocation.
I have serious doubts that this statement is correct.
Think about this comment and documentation as a boiler plate for the
mandatory man page for a new syscall (hint...)
> + *
> + */
and W=1 also complains rightfully here:
> +SYSCALL_DEFINE3(vgetrandom_alloc, unsigned int __user *, num,
> + unsigned int __user *, size_per_each, unsigned int, flags)
drivers/char/random.c:188: warning: expecting prototype for vgetrandom_alloc(). Prototype was for sys_vgetrandom_alloc() instead
> +{
> diff --git a/include/vdso/getrandom.h b/include/vdso/getrandom.h
> new file mode 100644
> index 000000000000..5f04c8bf4bd4
> --- /dev/null
> +++ b/include/vdso/getrandom.h
> @@ -0,0 +1,24 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * Copyright (C) 2022 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
> + */
> +
> +#ifndef _VDSO_GETRANDOM_H
> +#define _VDSO_GETRANDOM_H
> +
> +#include <crypto/chacha.h>
> +
> +struct vgetrandom_state {
> + union {
> + struct {
> + u8 batch[CHACHA_BLOCK_SIZE * 3 / 2];
> + u32 key[CHACHA_KEY_SIZE / sizeof(u32)];
> + };
> + u8 batch_key[CHACHA_BLOCK_SIZE * 2];
> + };
> + unsigned long generation;
> + u8 pos;
> + bool in_use;
> +};
Again, please make this properly tabular:
struct vgetrandom_state {
union {
struct {
u8 batch[CHACHA_BLOCK_SIZE * 3 / 2];
u32 key[CHACHA_KEY_SIZE / sizeof(u32)];
};
u8 batch_key[CHACHA_BLOCK_SIZE * 2];
};
unsigned long generation;
u8 pos;
bool in_use;
};
Plus some kernel doc which explains what this is about.
Thanks,
tglx
next prev parent reply other threads:[~2022-11-29 22: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 [this message]
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
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=87cz95v2q2.ffs@tglx \
--to=tglx@linutronix.de \
--cc=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=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.