RE: [PATCH 3/9 next] lib/iov_iter: Improved function for importing iovec[] from userpace.
From: David Laight
Date: Mon Sep 21 2020 - 10:58:01 EST
From: Christoph Hellwig
> Sent: 21 September 2020 15:11
>
> On Tue, Sep 15, 2020 at 02:55:17PM +0000, David Laight wrote:
> >
> > import_iovec() has a 'pointer by reference' parameter to pass in the
> > (on-stack) iov[] cache and return the address of a larger copy that
> > the caller must free.
> > This is non-intuitive, faffy to setup, and not that efficient.
> > Instead just pass in the address of the cache and return the address
> > to free (on success) or PTR_ERR() (on error).
>
> To me it seems pretty sensible, and in fact the conversions to your
> new API seem to add more lines than they remove.
They probably add a line because the two variables get defined on
separate lines.
The problem is the inefficiency of passing the addresses by 'double
reference'.
Although your suggestion of putting the 'address to free' in the
same structure as the cache does resolve that.
It also gets rid of all the PTR_ERR() faffing.
Still probably best to return 0 on success.
Plenty of code was converting the +ve to 0.
I might to a v2 on top of your compat iovec changes - once they
hit Linus's tree.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)