On 3/27/23 1:03?PM, Linus Torvalds wrote: > On Mon, Mar 27, 2023 at 11:04?AM Jens Axboe <axboe@xxxxxxxxx> wrote: >> >> --- a/fs/read_write.c >> +++ b/fs/read_write.c >> @@ -748,10 +748,21 @@ static ssize_t do_loop_readv_writev(struct file *filp, struct iov_iter *iter, >> if (flags & ~RWF_HIPRI) >> return -EOPNOTSUPP; >> >> + if (WARN_ON_ONCE(iter->iter_type != ITER_IOVEC && >> + iter->iter_type != ITER_UBUF)) >> + return -EINVAL; > > Hmm. I think it might actually be nicer for the "iter_is_ubuf(iter)" > case to be outside the loop entirely, and be done before this > WARN_ON_ONCE(). > > If it's a single ITER_UBUF, that code really shouldn't loop at all - > it's literally just the old case of "call ->read/write with a single > buffer". > > So i think I'd prefer this patch to be something along the lines of > this instead: See Al's suggestion in the other thread, I like that a lot better as it avoids any potential wack-a-mole with potentially similar cases. There are not a lot of hits for iov_iter_iovec() in the three and I spotted two, which lead to these two prep patches. But if we do: https://git.kernel.dk/cgit/linux-block/commit/?h=iter-ubuf&id=8a825a6f52e8fab74e936f15eea6c34ac67272f6 then we don't really have to worry about those. -- Jens Axboe