From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,viro@zeniv.linux.org.uk,tz2294@columbia.edu,
stable@vger.kernel.org,l1za0.sec@gmail.com,kbusch@kernel.org,hch@lst.de,
hare@kernel.org,brauner@kernel.org,axboe@kernel.dk,4ncienth@gmail.com,
akpm@linux-foundation.org
Subject: [merged] iov_iter-validate-extracted-segment-for-bvec-alignment.patch removed from -mm tree
Date: Thu, 19 Nov 2026 10:03:24 -0800 [thread overview]
Message-ID: <20261119180324.D39341F000C9@smtp.kernel.org> (raw)
In-Reply-To: <20261015061907.2713943-1-4ncienth@gmail.com>
The quilt patch titled
Subject: iov_iter: validate extracted segment for bvec alignment
has been removed from the -mm tree. Its filename was
iov_iter-validate-extracted-segment-for-bvec-alignment.patch
This patch was dropped because it was merged into mainline or a subsystem tree
------------------------------------------------------
From: Daehyeon Ko <4ncienth@gmail.com>
Subject: iov_iter: validate extracted segment for bvec alignment
Date: Thu, 15 Oct 2026 15:19:07 +0900
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.
The worst effect I have confirmed is an alignment-contract bypass. An
unprivileged O_DIRECT preadv() produced bvecs with offset/length pairs
(1, 4095) and (0, 1). The bio reached brd_submit_bio(), and the read
completed 4096 bytes instead of failing with -EINVAL.
I have not demonstrated harmful behavior on real DMA hardware. For a
normal blk-mq target, blk_mq_submit_bio() calls
__bio_split_to_limits(), where bio_split_io_at() rejects the misaligned
bvec before queue_rq(). Virtio-blk and loop both returned -EINVAL in
my controls.
So a bio-based driver can receive a bvec which violates its advertised
dma_alignment, but any further effect is driver-specific. I have not
reproduced memory corruption or a crash on real hardware.
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.
Link: https://patch.msgid.link/20261015061907.2713943-1-4ncienth@gmail.com
Fixes: 14b007e17881 ("block: validate user space vectors during extraction")
Signed-off-by: Daehyeon Ko <4ncienth@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Closes: https://lore.kernel.org/r/20261012065520.1089147-1-4ncienth@gmail.com
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Keith Busch <kbusch@kernel.org>
Cc: Hannes Reinecke <hare@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Haocheng Yu <l1za0.sec@gmail.com>
Cc: Tal Zussman <tz2294@columbia.edu>
Cc: Christian Brauner <brauner@kernel.org>
Cc: <stable@vger.kernel.org>
lib/iov_iter.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
--- a/lib/iov_iter.c~iov_iter-validate-extracted-segment-for-bvec-alignment
+++ a/lib/iov_iter.c
@@ -1042,7 +1042,7 @@ static ssize_t iter_xarray_get_pages(str
return maxsize;
}
-/* must be done on non-empty ITER_UBUF or ITER_IOVEC one */
+/* must be used on a non-empty ITER_UBUF, ITER_IOVEC or ITER_KVEC */
static unsigned long first_iovec_segment(const struct iov_iter *i, size_t *size)
{
size_t skip;
@@ -1959,8 +1959,13 @@ ssize_t iov_iter_extract_bvecs(struct io
iter_is_iovec(iter) ||
iov_iter_is_kvec(iter))) {
unsigned long start = (unsigned long)iter_iov_addr(iter);
+ size_t seg_size = min(iter_iov_len(iter), iter->count);
- if ((start | iter_iov_len(iter)) & mem_align_mask)
+ if (unlikely(!seg_size && iter->count)) {
+ seg_size = iter->count;
+ start = first_iovec_segment(iter, &seg_size);
+ }
+ if ((start | seg_size) & mem_align_mask)
return -EINVAL;
} else if (iov_iter_alignment(iter) & mem_align_mask) {
return -EINVAL;
_
Patches currently in -mm which might be from 4ncienth@gmail.com are
mm-hugetlb_cgroup-prevent-use-after-free-during-cgroup-offlining.patch
prev parent reply other threads:[~2026-11-19 18:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 6:19 [PATCH v2] iov_iter: validate extracted segment for bvec alignment Daehyeon Ko
2026-10-16 1:17 ` Andrew Morton
2026-10-16 2:44 ` Daehyeon Ko
2026-11-19 18:03 ` Andrew Morton [this message]
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=20261119180324.D39341F000C9@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=4ncienth@gmail.com \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=hare@kernel.org \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=l1za0.sec@gmail.com \
--cc=mm-commits@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tz2294@columbia.edu \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.