* [PATCH v3] iov_iter: Use iov_offset for length calculation in iov_iter_aligned_bvec [not found] <CGME20250428100738epcas5p3eb82b4ea94b229634f9319d23d7d7e14@epcas5p3.samsung.com> @ 2025-04-28 9:58 ` Nitesh Shetty 2025-05-13 11:25 ` Nitesh Shetty 2025-05-14 0:28 ` Andrew Morton 0 siblings, 2 replies; 3+ messages in thread From: Nitesh Shetty @ 2025-04-28 9:58 UTC (permalink / raw) To: Andrew Morton, Alexander Viro, Jens Axboe, Christian Brauner, Keith Busch Cc: gost.dev, nitheshshetty, Nitesh Shetty, linux-kernel If iov_offset is non-zero, then we need to consider iov_offset in length calculation, otherwise we might pass smaller IOs such as 512 bytes, in below scenario[1]. This issue is reproducible using lib-uring test/fixed-seg.c application with fixed buffer on a 512 LBA formatted device. [1] At present we pass the alignment check, for 512 LBA formatted devices, len_mask = 511 when IO is smaller, i->count = 512 has an offset, i->io_offset = 3584 with bvec values, bvec->bv_offset = 256, bvec->bv_len = 3840. In short, the first 256 bytes are in the current page, next 256 bytes are in the another page. Ideally we expect to fail the IO. Fixes: 2263639f96f2 ("iov_iter: streamline iovec/bvec alignment iteration") Reviewed-by: Jens Axboe <axboe@kernel.dk> Reviewed-by: Anuj Gupta <anuj20.g@samsung.com> Signed-off-by: Nitesh Shetty <nj.shetty@samsung.com> --- lib/iov_iter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/iov_iter.c b/lib/iov_iter.c index bc9391e55d57..9ce83ab71bac 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -820,7 +820,7 @@ static bool iov_iter_aligned_bvec(const struct iov_iter *i, unsigned addr_mask, size_t size = i->count; do { - size_t len = bvec->bv_len; + size_t len = bvec->bv_len - skip; if (len > size) len = size; base-commit: 02ddfb981de88a2c15621115dd7be2431252c568 -- 2.43.0 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] iov_iter: Use iov_offset for length calculation in iov_iter_aligned_bvec 2025-04-28 9:58 ` [PATCH v3] iov_iter: Use iov_offset for length calculation in iov_iter_aligned_bvec Nitesh Shetty @ 2025-05-13 11:25 ` Nitesh Shetty 2025-05-14 0:28 ` Andrew Morton 1 sibling, 0 replies; 3+ messages in thread From: Nitesh Shetty @ 2025-05-13 11:25 UTC (permalink / raw) To: Nitesh Shetty Cc: Andrew Morton, Alexander Viro, Jens Axboe, Christian Brauner, Keith Busch, gost.dev, linux-kernel On Mon, Apr 28, 2025 at 4:23 PM Nitesh Shetty <nj.shetty@samsung.com> wrote: > > If iov_offset is non-zero, then we need to consider iov_offset in length > calculation, otherwise we might pass smaller IOs such as 512 bytes, in > below scenario[1]. > This issue is reproducible using lib-uring test/fixed-seg.c application > with fixed buffer on a 512 LBA formatted device. > > [1] > At present we pass the alignment check, > for 512 LBA formatted devices, len_mask = 511 > when IO is smaller, i->count = 512 > has an offset, i->io_offset = 3584 > with bvec values, bvec->bv_offset = 256, bvec->bv_len = 3840. > In short, the first 256 bytes are in the current page, > next 256 bytes are in the another page. > Ideally we expect to fail the IO. > > Fixes: 2263639f96f2 ("iov_iter: streamline iovec/bvec alignment iteration") > Reviewed-by: Jens Axboe <axboe@kernel.dk> > Reviewed-by: Anuj Gupta <anuj20.g@samsung.com> > Signed-off-by: Nitesh Shetty <nj.shetty@samsung.com> > --- Hi Andrew, Can you review and pick this change ? Thank you, Nitesh ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] iov_iter: Use iov_offset for length calculation in iov_iter_aligned_bvec 2025-04-28 9:58 ` [PATCH v3] iov_iter: Use iov_offset for length calculation in iov_iter_aligned_bvec Nitesh Shetty 2025-05-13 11:25 ` Nitesh Shetty @ 2025-05-14 0:28 ` Andrew Morton 1 sibling, 0 replies; 3+ messages in thread From: Andrew Morton @ 2025-05-14 0:28 UTC (permalink / raw) To: Nitesh Shetty Cc: Alexander Viro, Jens Axboe, Christian Brauner, Keith Busch, gost.dev, nitheshshetty, linux-kernel On Mon, 28 Apr 2025 15:28:48 +0530 Nitesh Shetty <nj.shetty@samsung.com> wrote: > If iov_offset is non-zero, then we need to consider iov_offset in length > calculation, otherwise we might pass smaller IOs such as 512 bytes, in > below scenario[1]. > This issue is reproducible using lib-uring test/fixed-seg.c application > with fixed buffer on a 512 LBA formatted device. > > [1] > At present we pass the alignment check, > for 512 LBA formatted devices, len_mask = 511 > when IO is smaller, i->count = 512 > has an offset, i->io_offset = 3584 > with bvec values, bvec->bv_offset = 256, bvec->bv_len = 3840. > In short, the first 256 bytes are in the current page, > next 256 bytes are in the another page. > Ideally we expect to fail the IO. Thanks. Can you please send us a description of the userspace-visible effects of this issue? That will help others to determine whether a -stable backport is desirable and it will be helpful to people who are wondering whether this patch will fix an issue they are experiencing. ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-14 0:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20250428100738epcas5p3eb82b4ea94b229634f9319d23d7d7e14@epcas5p3.samsung.com>
2025-04-28 9:58 ` [PATCH v3] iov_iter: Use iov_offset for length calculation in iov_iter_aligned_bvec Nitesh Shetty
2025-05-13 11:25 ` Nitesh Shetty
2025-05-14 0:28 ` Andrew Morton
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®