Skip to contentSkip to conversation

filemap-fix-the-conditional-folio_put-in-filemap_fault.patch removed from -mm tree

merged mm-hotfixes-stable Andrew Morton 2 participants 6 messages May 5, 2023 – May 6, 2023

Subsystems (2)
lore
Share & tools
lore

Andrew Morton

author maintainer tree notice Applied
#0 lore raw

The quilt patch titled
Subject: filemap: fix the conditional folio_put in filemap_fault
has been removed from the -mm tree. Its filename was
filemap-fix-the-conditional-folio_put-in-filemap_fault.patch

This patch was dropped because it was merged into the mm-hotfixes-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Christoph Hellwig <[email protected]>
Subject: filemap: fix the conditional folio_put in filemap_fault
Date: Wed, 3 May 2023 17:45:25 +0200

folio can't be NULL here now that __filemap_get_folio returns an ERR_PTR. Remove the conditional folio_put after the out_retry label and add a new label for the cases where we have a valid folio.

Fixes 66dabbb65d67 ("mm: return an ERR_PTR from __filemap_get_folio")
Reported-by [email protected]
Cc Matthew Wilcox <[email protected]>
Cc David Howells <[email protected]>
Cc Marc Dionne <[email protected]>

---

 mm/filemap.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
mm/filemap.c renamed from mm/filemap.c~filemap-fix-the-conditional-folio_put-in-filemap_fault +5 -5
@@ -3298,7 +3298,7 @@ retry_find:
 	}
 
 	if (!lock_folio_maybe_drop_mmap(vmf, folio, &fpin))
-		goto out_retry;
+		goto out_retry_put_folio;
 
 	/* Did it get truncated? */
 	if (unlikely(folio->mapping != mapping)) {
@@ -3334,7 +3334,7 @@ retry_find:
 	 */
 	if (fpin) {
 		folio_unlock(folio);
-		goto out_retry;
+		goto out_retry_put_folio;
 	}
 	if (mapping_locked)
 		filemap_invalidate_unlock_shared(mapping);
@@ -3363,7 +3363,7 @@ page_not_uptodate:
 	fpin = maybe_unlock_mmap_for_io(vmf, fpin);
 	error = filemap_read_folio(file, mapping->a_ops->read_folio, folio);
 	if (fpin)
-		goto out_retry;
+		goto out_retry_put_folio;
 	folio_put(folio);
 
 	if (!error || error == AOP_TRUNCATED_PAGE)
@@ -3372,14 +3372,14 @@ page_not_uptodate:
 
 	return VM_FAULT_SIGBUS;
 
+out_retry_put_folio:
+	folio_put(folio);
 out_retry:
 	/*
 	 * We dropped the mmap_lock, we need to return to the fault handler to
 	 * re-find the vma and come back and find our hopefully still populated
 	 * page.
 	 */
-	if (folio)
-		folio_put(folio);
 	if (mapping_locked)
 		filemap_invalidate_unlock_shared(mapping);
 	if (fpin)

_

Patches currently in -mm which might be from [email protected] are

maintainer
#1 lore raw
Quoted 8 lines · Andrew Morton

The quilt patch titled
Subject: filemap: fix the conditional folio_put in filemap_fault
has been removed from the -mm tree. Its filename was
filemap-fix-the-conditional-folio_put-in-filemap_fault.patch

This patch was dropped because it was merged into the mm-hotfixes-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

I thought i nacked this?

Quoted 74 lines

------------------------------------------------------
From: Christoph Hellwig <[email protected]>
Subject: filemap: fix the conditional folio_put in filemap_fault
Date: Wed, 3 May 2023 17:45:25 +0200

folio can't be NULL here now that __filemap_get_folio returns an ERR_PTR. Remove the conditional folio_put after the out_retry label and add a new label for the cases where we have a valid folio.

Fixes 66dabbb65d67 ("mm: return an ERR_PTR from __filemap_get_folio")
Reported-by [email protected]
Cc Matthew Wilcox <[email protected]>
Cc David Howells <[email protected]>
Cc Marc Dionne <[email protected]>

---

 mm/filemap.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
mm/filemap.c renamed from mm/filemap.c~filemap-fix-the-conditional-folio_put-in-filemap_fault +5 -5
@@ -3298,7 +3298,7 @@ retry_find:
 	}
 
 	if (!lock_folio_maybe_drop_mmap(vmf, folio, &fpin))
-		goto out_retry;
+		goto out_retry_put_folio;
 
 	/* Did it get truncated? */
 	if (unlikely(folio->mapping != mapping)) {
@@ -3334,7 +3334,7 @@ retry_find:
 	 */
 	if (fpin) {
 		folio_unlock(folio);
-		goto out_retry;
+		goto out_retry_put_folio;
 	}
 	if (mapping_locked)
 		filemap_invalidate_unlock_shared(mapping);
@@ -3363,7 +3363,7 @@ page_not_uptodate:
 	fpin = maybe_unlock_mmap_for_io(vmf, fpin);
 	error = filemap_read_folio(file, mapping->a_ops->read_folio, folio);
 	if (fpin)
-		goto out_retry;
+		goto out_retry_put_folio;
 	folio_put(folio);
 
 	if (!error || error == AOP_TRUNCATED_PAGE)
@@ -3372,14 +3372,14 @@ page_not_uptodate:
 
 	return VM_FAULT_SIGBUS;
 
+out_retry_put_folio:
+	folio_put(folio);
 out_retry:
 	/*
 	 * We dropped the mmap_lock, we need to return to the fault handler to
 	 * re-find the vma and come back and find our hopefully still populated
 	 * page.
 	 */
-	if (folio)
-		folio_put(folio);
 	if (mapping_locked)
 		filemap_invalidate_unlock_shared(mapping);
 	if (fpin)

_

Patches currently in -mm which might be from [email protected] are

author maintainer
#2 lore raw
Quoted 11 lines · On Sat, 6 May 2023 00:05:57 +0100 Matthew Wilcox <[email protected]> wrote:
Quoted 8 lines · Andrew Morton

The quilt patch titled
Subject: filemap: fix the conditional folio_put in filemap_fault
has been removed from the -mm tree. Its filename was
filemap-fix-the-conditional-folio_put-in-filemap_fault.patch

This patch was dropped because it was merged into the mm-hotfixes-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

I thought i nacked this?

This? https://lkml.kernel.org/r/[email protected]

I interpret that as "doh, never mind"?

maintainer
#3 lore raw
Quoted 9 lines · Andrew Morton
Quoted 7 lines · On Sat, 6 May 2023 00:05:57 +0100 Matthew Wilcox <[email protected]> wrote:
Quoted 6 lines · Andrew Morton

The quilt patch titled
Subject: filemap: fix the conditional folio_put in filemap_fault
has been removed from the -mm tree. Its filename was
filemap-fix-the-conditional-folio_put-in-filemap_fault.patch

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

This patch was dropped because it was merged into the mm-hotfixes-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

I thought i nacked this?

This? https://lkml.kernel.org/r/[email protected]

I interpret that as "doh, never mind"?

This patch is what I want to see merged:

mm/filemap.c +1 -1
index a34abfe8c654..b4c9bd368b7e 100644
@@ -3378,7 +3378,7 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)
 	 * re-find the vma and come back and find our hopefully still populated
 	 * page.
 	 */
-	if (folio)
+	if (!IS_ERR(folio))
 		folio_put(folio);
 	if (mapping_locked)
 		filemap_invalidate_unlock_shared(mapping);
author maintainer
#4 lore raw
Quoted 26 lines · On Sat, 6 May 2023 00:42:36 +0100 Matthew Wilcox <[email protected]> wrote:
Quoted 9 lines · Andrew Morton
Quoted 7 lines · On Sat, 6 May 2023 00:05:57 +0100 Matthew Wilcox <[email protected]> wrote:
Quoted 6 lines · Andrew Morton

The quilt patch titled
Subject: filemap: fix the conditional folio_put in filemap_fault
has been removed from the -mm tree. Its filename was
filemap-fix-the-conditional-folio_put-in-filemap_fault.patch

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

This patch was dropped because it was merged into the mm-hotfixes-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

I thought i nacked this?

This? https://lkml.kernel.org/r/[email protected]

I interpret that as "doh, never mind"?

This patch is what I want to see merged:

...

mm/filemap.c vm_fault_t filemap_fault(struct vm_fault *vmf) · line 3384

Quoted 8 lines
mm/filemap.c +1 -1
@@ -3378,7 +3378,7 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)
 	 * re-find the vma and come back and find our hopefully still populated
 	 * page.
 	 */
-	if (folio)
+	if (!IS_ERR(folio))
 		folio_put(folio);
 	if (mapping_locked)
 		filemap_invalidate_unlock_shared(mapping);

Oh. And hch preferred the label approach. I'll stick with the patch as-is. Please send an alteration if you feel sufficiently strongly about it.

maintainer
#5 lore raw
Quoted 6 lines · Andrew Morton
Quoted 1 line · On Sat, 6 May 2023 00:42:36 +0100 Matthew Wilcox <[email protected]> wrote:

This patch is what I want to see merged:

Oh. And hch preferred the label approach. I'll stick with the patch as-is. Please send an alteration if you feel sufficiently strongly about it.

I'm supposed to be the maintainer. My preference trumps Christoph's.