From: Andrew Morton <akpm@linux-foundation.org>
To: Daehyeon Ko <4ncienth@gmail.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
Jens Axboe <axboe@kernel.dk>, Keith Busch <kbusch@kernel.org>,
Hannes Reinecke <hare@kernel.org>,
linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] iov_iter: validate extracted segment for bvec alignment
Date: Thu, 15 Oct 2026 18:17:02 -0700 [thread overview]
Message-ID: <20261015181702.21329d323eb40d145a6d0c9d@linux-foundation.org> (raw)
In-Reply-To: <20261015061907.2713943-1-4ncienth@gmail.com>
On Thu, 15 Oct 2026 15:19:07 +0900 Daehyeon Ko <4ncienth@gmail.com> wrote:
> iov_iter_extract_bvecs() validates iter_iov_addr() and iter_iov_len()
> before iov_iter_extract_pages() selects the first nonempty segment and
> limits it by iter->count. The checks can therefore cover a different range
> after a leading empty segment or iov_iter_truncate().
>
> An unprivileged O_DIRECT preadv() reproduced the empty-segment case: an
> aligned empty segment followed by a misaligned one completed 4096 bytes
> instead of returning -EINVAL. A truncated iterator has the same mismatch
> when its full segment length is aligned but its remaining count is not.
>
> Bound the normal fast-path length by iter->count. Keep
> first_iovec_segment() for leading empty segments so validation covers the
> remaining portion of the segment available for extraction.
Thanks.
I'd like to understand the worst-case userspace-visible runtime effects
of this bug. As far as I understand, the existing bug can result in
misaligned DMA requests getting all the way down to the device driver,
yes?
If so, hopefully the driver and the hardware will handle this elegantly
(hah), but there are so many drivers and they aren't the best code
we've ever produced.
Your patch has cc:stable and I agree with that decision. Jens?
next prev parent reply other threads:[~2026-10-16 1:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 6:19 Daehyeon Ko
2026-10-16 1:17 ` Andrew Morton [this message]
2026-10-16 2:44 ` Daehyeon Ko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261015181702.21329d323eb40d145a6d0c9d@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=4ncienth@gmail.com \
--cc=axboe@kernel.dk \
--cc=hare@kernel.org \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®