On Thu, May 26, 2022 at 11:13:52AM -0700, Eric Biggers wrote: > On Thu, May 26, 2022 at 07:50:45AM -0600, Keith Busch wrote: > > On Thu, May 26, 2022 at 12:29:41AM -0700, Eric Biggers wrote: > > > On Wed, May 25, 2022 at 06:06:12PM -0700, Keith Busch wrote: > > > > + /* > > > > + * Each segment in the iov is required to be a block size multiple. > > > > > > Where is this enforced? > > > > Right below the comment. If it isn't a block size multiple, then ALIGN_DOWN > > will eventually result in 0 and -EFAULT is returned. > > That's interesting, I would have expected it to be checked in > blkdev_dio_aligned(). That would require a change to the iov_iter_alignment API, or a new function entirely. > EFAULT isn't the correct error code for this case; it should be EINVAL as is > normally the case for bad alignment. See the man pages for read and write. The EFAULT was just to get the do-while loop to break out. The callers in this patch still return EINVAL when it sees the iov_iter hasn't advanced to the end. But there are some cases where the EFAULT would be returned to the user. Let me see how difficult it would be catch it early in blkdev_dio_aligned().