# Re: \[PATCH v9 1/9\] iov\_iter: add copy\_struct\_from\_iter()

- From: Omar Sandoval \<osandov@osandov.com\>
- Date: 2021-04-02 07:33:27 
- List: linux-api
- Page: https://ratatoskr.run/linux-api/2021/04/203145
- Thread: https://ratatoskr.run/linux-fsdevel/2021/04/203041/t.md

```text
On Thu, Apr 01, 2021 at 09:05:22AM -0700, Linus Torvalds wrote:
> On Wed, Mar 31, 2021 at 11:51 PM Omar Sandoval [ref] wrote:
> >
> > + *
> > + * The recommended usage is something like the following:
> > + *
> > + *     if (usize > PAGE_SIZE)
> > + *       return -E2BIG;
> 
> Maybe this should be more than a recommendation, and just be inside
> copy_struct_from_iter(), because otherwise the "check_zeroed_user()"
> call might be quite the timesink for somebody who does something
> stupid.

I did actually almost send this out with the check in
copy_struct_from_iter(), but decided not to for consistency with
copy_struct_from_user().

openat2() seems to be the only user of copy_struct_from_user() that
doesn't limit to PAGE_SIZE, which is odd given that Aleksa wrote both
openat2() and copy_struct_from_user(). Aleksa, was this intentional?

Thanks,
Omar
```
