From: sashiko-bot@kernel.org
To: "SJ Park" <sj@kernel.org>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
damon@lists.linux.dev, linux-mm@kvack.org
Subject: Re: [RFC PATCH v3 3/7] mm/damon/vaddr: implement sz_filter_passed for migrate_{hot,cold} action
Date: Fri, 27 Nov 2026 22:35:53 +0000 [thread overview]
Message-ID: <sashiko-outbox-238334@kernel.org> (raw)
In-Reply-To: <20261127222719.105510-4-sj@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] mm/damon/vaddr: NULL folio dereference in
damos_va_migrate_pmd_entry()
--
commit 446fe1a8fb2f01d2025ab8ed2dd156f643ec9800
Author: SJ Park <sj@kernel.org>
mm/damon/vaddr: implement sz_filter_passed for migrate_{hot,cold} action
This commit threads sz_filter_passed through damos_va_migrate() and
damos_va_migrate_pmd_entry() to accumulate the size of folios that pass
DAMOS ops filters during migrate_{hot,cold} actions.
> diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
> index c8f93a19c840e..721a23856ee16 100644
> --- a/mm/damon/vaddr.c
> +++ b/mm/damon/vaddr.c
[ ... ]
> @@ -895,6 +898,7 @@ static int damos_va_migrate_pmd_entry(pmd_t *pmd, unsigned long addr,
> s->last_applied = folio;
> if (damos_va_filter_out(s, folio, walk->vma, addr, pte, NULL))
> continue;
> + *sz_filter_passed += folio_size(folio);
> damos_va_migrate_dests_add(folio, walk->vma, addr, s,
> migration_lists);
> }
[Severity: High]
Can the PTE loop in damos_va_migrate_pmd_entry() dereference a NULL folio
when vm_normal_folio() returns NULL (for example, on the shared zero page
or a special mapping)?
Earlier in this series, commit "mm/damon/vaddr: use damos->last_applied
for migrate action" placed damos_va_invalid_folio() (which checks !folio)
after folio_page_idx() and folio_nr_pages():
mm/damon/vaddr.c:damos_va_migrate_pmd_entry() {
...
folio = vm_normal_folio(walk->vma, addr, ptent);
page_idx = folio_page_idx(folio, pte_page(ptent));
nr = folio_nr_pages(folio) - page_idx;
if (damos_va_invalid_folio(folio, s))
continue;
...
}
When folio is NULL, folio_nr_pages() dereferences NULL while holding the
page table lock. Checking !folio (or calling damos_va_invalid_folio() or
checking !folio before computing page_idx and nr, as in
damos_va_stat_pmd_entry()) avoids the NULL pointer dereference.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127222719.105510-1-sj@kernel.org?part=3
next prev parent reply other threads:[~2026-11-27 22:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 22:27 [RFC PATCH v3 0/7] mm/damon: various improvements/cleanups for code, tests and comments SJ Park
2026-11-27 22:27 ` [RFC PATCH v3 1/7] mm/damon/vaddr: advance migration attempt in folio level for filter out SJ Park
2026-11-27 22:27 ` [RFC PATCH v3 2/7] mm/damon/vaddr: use damos->last_applied for migrate action SJ Park
2026-11-27 22:33 ` sashiko-bot
2026-11-27 22:39 ` SJ Park
2026-11-27 22:27 ` [RFC PATCH v3 3/7] mm/damon/vaddr: implement sz_filter_passed for migrate_{hot,cold} action SJ Park
2026-11-27 22:35 ` sashiko-bot [this message]
2026-11-27 22:41 ` SJ Park
2026-11-27 22:27 ` [RFC PATCH v3 4/7] mm/damon/sysfs-schemes: drop redundant and racy zero target_value check SJ Park
2026-11-27 22:27 ` [RFC PATCH v3 5/7] selftests/damon/damos_apply_interval: remove unused variables SJ Park
2026-11-27 22:27 ` [RFC PATCH v3 6/7] selftests/damon: remove unused imports of sys and time modules SJ Park
2026-11-27 22:27 ` [RFC PATCH v3 7/7] mm/damon: update file intro comments to call DAMON just DAMON SJ Park
2026-11-27 22:35 ` [RFC PATCH v3 0/7] mm/damon: various improvements/cleanups for code, tests and comments sashiko-bot
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=sashiko-outbox-238334@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=linux-mm@kvack.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sj@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.