Patch "s390/uv: Don't call folio_wait_writeback() without a folio reference" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    s390/uv: Don't call folio_wait_writeback() without a folio reference

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     s390-uv-don-t-call-folio_wait_writeback-without-a-fo.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit a9da14f5b6e51ae2c623ec5fedb06b5c50eb4398
Author: David Hildenbrand <david@xxxxxxxxxx>
Date:   Wed May 8 20:29:46 2024 +0200

    s390/uv: Don't call folio_wait_writeback() without a folio reference
    
    [ Upstream commit 3f29f6537f54d74e64bac0a390fb2e26da25800d ]
    
    folio_wait_writeback() requires that no spinlocks are held and that
    a folio reference is held, as documented. After we dropped the PTL, the
    folio could get freed concurrently. So grab a temporary reference.
    
    Fixes: 214d9bbcd3a6 ("s390/mm: provide memory management functions for protected KVM guests")
    Reviewed-by: Claudio Imbrenda <imbrenda@xxxxxxxxxxxxx>
    Signed-off-by: David Hildenbrand <david@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20240508182955.358628-2-david@xxxxxxxxxx
    Signed-off-by: Heiko Carstens <hca@xxxxxxxxxxxxx>
    Signed-off-by: Alexander Gordeev <agordeev@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/s390/kernel/uv.c b/arch/s390/kernel/uv.c
index 8c73d4901e145..03a8a9a52186a 100644
--- a/arch/s390/kernel/uv.c
+++ b/arch/s390/kernel/uv.c
@@ -320,6 +320,13 @@ int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb)
 			rc = make_folio_secure(folio, uvcb);
 			folio_unlock(folio);
 		}
+
+		/*
+		 * Once we drop the PTL, the folio may get unmapped and
+		 * freed immediately. We need a temporary reference.
+		 */
+		if (rc == -EAGAIN)
+			folio_get(folio);
 	}
 unlock:
 	pte_unmap_unlock(ptep, ptelock);
@@ -332,6 +339,7 @@ int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb)
 		 * completion, this is just a useless check, but it is safe.
 		 */
 		folio_wait_writeback(folio);
+		folio_put(folio);
 	} else if (rc == -EBUSY) {
 		/*
 		 * If we have tried a local drain and the folio refcount




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux