Re: [PATCH v9 1/9] iov_iter: add copy_struct_from_iter()

From
Omar Sandoval <osandov@osandov.com>
Date
2021-04-02 17:50:55
Also in
linux-btrfs, linux-fsdevel
Reply to
Christian Brauner, 2021-04-02
On Fri, Apr 02, 2021 at 10:04:23AM +0200, Christian Brauner wrote:
On Fri, Apr 02, 2021 at 12:33:20AM -0700, Omar Sandoval wrote:
quoted
On Thu, Apr 01, 2021 at 09:05:22AM -0700, Linus Torvalds wrote:
quoted
On Wed, Mar 31, 2021 at 11:51 PM Omar Sandoval [off-list ref] wrote:
quoted

+ *
+ * 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
Al said there's nothing wrong with copying large chunks of memory so we
shouldn't limit the helper but instead limit the callers which have
expectations about their size limit:
https://lore.kernel.org/lkml/20190905182801.GR1131@ZenIV.linux.org.uk/ (local)
Thanks for the context. So I guess it makes sense to keep the check
"recommended" for both functions.
Thread (14 messages) 14 messages, 3 authors, last reply 2021-04-02
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help