RE: [PATCH RFC] Introduce uniptr_t as a generic "universal" pointer

From: David Laight
Date: Mon Aug 14 2023 - 12:07:40 EST


From: Linus Torvalds
> Sent: 09 August 2023 16:59
>
> On Wed, 9 Aug 2023 at 07:44, Takashi Iwai <tiwai@xxxxxxx> wrote:
> >
> > The remaining question is whether the use of sockptr_t for other
> > subsystems as a generic pointer is a recommended / acceptable move...
>
> Very much not recommended. sockptr_t is horrible too, but it was (part
> of) what made it possible to fix an even worse horrible historical
> mistake (ie getting rid of set_fs()).
>
> So I detest sockptr_t. It's garbage. At the very minimum it should
> have had the length associated with it, not passed separately.

FWIW I've thought you'd want something like:
struct ptr_arg {
void *kernel;
void __user *user;
unsigned int kernel_len;
unsigned int user_len;
};

Then [gs]etsockopt() could copy short user buffers into
kernel space (eg on stack) while allowing code that needs
very large buffers (eg some sctp options) to directly
access a userspace buffer.

There certainly used to be sockopt calls where the user
didn't pass the correct/any length.
They might all have been in decnet.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)