From: Greg Kroah-Hartman Date: Fri, 29 Mar 2024 12:52:13 +0000 (+0100) Subject: 6.1-stable patches X-Git-Tag: v6.7.12~154 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b8399c597ea3bfc095ee3a734a195385bf981cf2;p=thirdparty%2Fkernel%2Fstable-queue.git 6.1-stable patches added patches: block-fix-page-refcounts-for-unaligned-buffers-in-__bio_release_pages.patch --- diff --git a/queue-6.1/block-fix-page-refcounts-for-unaligned-buffers-in-__bio_release_pages.patch b/queue-6.1/block-fix-page-refcounts-for-unaligned-buffers-in-__bio_release_pages.patch new file mode 100644 index 00000000000..6735f133f6d --- /dev/null +++ b/queue-6.1/block-fix-page-refcounts-for-unaligned-buffers-in-__bio_release_pages.patch @@ -0,0 +1,52 @@ +From 38b43539d64b2fa020b3b9a752a986769f87f7a6 Mon Sep 17 00:00:00 2001 +From: Tony Battersby +Date: Thu, 29 Feb 2024 13:08:09 -0500 +Subject: block: Fix page refcounts for unaligned buffers in __bio_release_pages() + +From: Tony Battersby + +commit 38b43539d64b2fa020b3b9a752a986769f87f7a6 upstream. + +Fix an incorrect number of pages being released for buffers that do not +start at the beginning of a page. + +Fixes: 1b151e2435fc ("block: Remove special-casing of compound pages") +Cc: stable@vger.kernel.org +Signed-off-by: Tony Battersby +Tested-by: Greg Edwards +Link: https://lore.kernel.org/r/86e592a9-98d4-4cff-a646-0c0084328356@cybernetics.com +Signed-off-by: Jens Axboe +[ Tony: backport to v6.1 by replacing bio_release_page() loop with + folio_put_refs() as commits fd363244e883 and e4cc64657bec are not + present. ] +Signed-off-by: Greg Kroah-Hartman +--- + block/bio.c | 11 ++++------- + 1 file changed, 4 insertions(+), 7 deletions(-) + +--- a/block/bio.c ++++ b/block/bio.c +@@ -1112,19 +1112,16 @@ void __bio_release_pages(struct bio *bio + struct folio_iter fi; + + bio_for_each_folio_all(fi, bio) { +- struct page *page; +- size_t done = 0; ++ size_t nr_pages; + + if (mark_dirty) { + folio_lock(fi.folio); + folio_mark_dirty(fi.folio); + folio_unlock(fi.folio); + } +- page = folio_page(fi.folio, fi.offset / PAGE_SIZE); +- do { +- folio_put(fi.folio); +- done += PAGE_SIZE; +- } while (done < fi.length); ++ nr_pages = (fi.offset + fi.length - 1) / PAGE_SIZE - ++ fi.offset / PAGE_SIZE + 1; ++ folio_put_refs(fi.folio, nr_pages); + } + } + EXPORT_SYMBOL_GPL(__bio_release_pages); diff --git a/queue-6.1/series b/queue-6.1/series index 07758be63a2..d5295d74a3e 100644 --- a/queue-6.1/series +++ b/queue-6.1/series @@ -196,3 +196,4 @@ x86-fpu-keep-xfd_state-in-sync-with-msr_ia32_xfd.patch efi-fix-panic-in-kdump-kernel.patch pwm-img-fix-pwm-clock-lookup.patch tty-serial-imx-fix-broken-rs485.patch +block-fix-page-refcounts-for-unaligned-buffers-in-__bio_release_pages.patch