Skip to content

Commit 0d24852

Browse files
osandovbrauner
authored andcommitted
iov_iter: fix advancing slot in iter_folioq_get_pages()
iter_folioq_get_pages() decides to advance to the next folioq slot when it has reached the end of the current folio. However, it is checking offset, which is the beginning of the current part, instead of iov_offset, which is adjusted to the end of the current part, so it doesn't advance the slot when it's supposed to. As a result, on the next iteration, we'll use the same folio with an out-of-bounds offset and return an unrelated page. This manifested as various crashes and other failures in 9pfs in drgn's VM testing setup and BPF CI. Fixes: db0aa2e ("mm: Define struct folio_queue and ITER_FOLIOQ to handle a sequence of folios") Link: https://lore.kernel.org/linux-fsdevel/[email protected]/ Tested-by: Manu Bretelle <[email protected]> Signed-off-by: Omar Sandoval <[email protected]> Link: https://lore.kernel.org/r/cbaf141ba6c0e2e209717d02746584072844841a.1727722269.git.osandov@fb.com Tested-by: Eduard Zingerman <[email protected]> Tested-by: Leon Romanovsky <[email protected]> Tested-by: Joey Gouly <[email protected]> Acked-by: David Howells <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent e32cde8 commit 0d24852

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/iov_iter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ static ssize_t iter_folioq_get_pages(struct iov_iter *iter,
10331033
if (maxpages == 0 || extracted >= maxsize)
10341034
break;
10351035

1036-
if (offset >= fsize) {
1036+
if (iov_offset >= fsize) {
10371037
iov_offset = 0;
10381038
slot++;
10391039
if (slot == folioq_nr_slots(folioq) && folioq->next) {

0 commit comments

Comments
 (0)