mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Folio-related bug in __iov_iter_get_pages_alloc()?
@ 2026-09-29 12:52 David Howells
  0 siblings, 0 replies; only message in thread
From: David Howells @ 2026-09-29 12:52 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: dhowells, Alexander Viro, Christoph Hellwig, linux-block,
	linux-fsdevel, linux-kernel

Hi Willy,

I'm looking at __iov_iter_get_pages_alloc() and when it's extracting from an
ITER_BVEC, I see:

		for (int k = 0; k < n; k++) {
			struct folio *folio = page_folio(page + k);
			p[k] = page + k;
			if (!folio_test_slab(folio))
				folio_get(folio);
		}

Isn't this wrong?  You can't assume the page you're looking at is a folio, and
so you shouldn't use page_folio() on it until you've checked what it is.
Granted, it's quite likely to be a folio, but not only could it be a slab
page, it could also be a randomly allocated page used as a buffer, a network
receive buffer or something allocated with a fragment allocator.

Can we actually safely use folio_get() with all of those, or do we need to use
get_page()?  (I know, at moment, get_page() is a wrapper around folio_get(),
but that's likely not to remain the case).

David


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-29 12:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-29 12:52 Folio-related bug in __iov_iter_get_pages_alloc()? David Howells

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®