mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guilherme Giacomo Simoes <trintaeoitogc@gmail.com>
To: akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org,
	liam@infradead.org, vbabka@kernel.org, rppt@kernel.org,
	surenb@google.com, mhocko@suse.com
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Guilherme Giacomo Simoes <trintaeoitogc@gmail.com>
Subject: [PATCH] mm: clear pmd in pmdp_invalidate()
Date: Tue, 27 Oct 2026 08:38:13 -0300	[thread overview]
Message-ID: <20261027113813.1332096-1-trintaeoitogc@gmail.com> (raw)

when attempt to do a madvise in a chunk of memory allocated by mmap, the
folio_split is called to split a portion of memory, and despite the path
leads to pmd_mkinvalid() they do not clear the pmd and clearer wording,
leading to a BUG_ON inside page_table_check_set() because the map count
is more than 1.

Call the page_table_check_pmd_clear() inside pmdp_invalidate() generic
function to ensure that the pmd will have they map count decrement.

Signed-off-by: Guilherme Giacomo Simoes <trintaeoitogc@gmail.com>
---
 mm/pgtable-generic.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c
index b91b1a98029c..7fa5351c75a0 100644
--- a/mm/pgtable-generic.c
+++ b/mm/pgtable-generic.c
@@ -203,6 +203,7 @@ pmd_t pmdp_invalidate(struct vm_area_struct *vma, unsigned long address,
 {
 	VM_WARN_ON_ONCE(!pmd_present(*pmdp));
 	pmd_t old = pmdp_establish(vma, address, pmdp, pmd_mkinvalid(*pmdp));
+	page_table_check_pmd_clear(vma->vm_mm, address, old);
 	flush_pmd_tlb_range(vma, address, address + HPAGE_PMD_SIZE);
 	return old;
 }
-- 
2.52.0


             reply	other threads:[~2026-10-27 11:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27 11:38 Guilherme Giacomo Simoes [this message]
2026-10-27 12:11 ` David Hildenbrand (Arm)
2026-10-27 14:09   ` Guilherme Giacomo Simoes
2026-10-27 14:50     ` Guilherme Giacomo Simoes
2026-10-27 23:10 ` [syzbot ci] " syzbot ci

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261027113813.1332096-1-trintaeoitogc@gmail.com \
    --to=trintaeoitogc@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=rppt@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®