From: sashiko-bot@kernel.org
To: "SJ Park" <sj@kernel.org>
Cc: damon@lists.linux.dev
Subject: Re: [PATCH 5.15.y] mm/damon/vaddr: drop last same folio access check optimization
Date: Wed, 09 Sep 2026 06:17:35 +0000 [thread overview]
Message-ID: <20260909061736.6830A1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260909060736.273661-1-sj@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Lockless PMD read without pmdp_get_lockless() causes torn reads on architectures with non-atomic PMD accesses.
--
commit 9322a55f3a2ea66cbeb4b3b0525204fccdd0b8a4
Author: SJ Park <sj@kernel.org>
Subject: mm/damon/vaddr: drop last same folio access check optimization
This commit drops an optimization in DAMON's virtual memory access check
that reused results if the region fell within the last checked page. The
optimization was removed because it could race when multiple kdamonds are
running and its actual impact was questionable.
Link: https://lore.kernel.org/20260715031002.108504-4-sj@kernel.org
Link: https://lore.kernel.org/20260621204050.10993-1-sj@kernel.org [1]
> diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
> index dbb0f0fb2e598..bc0034b235d83 100644
> --- a/mm/damon/vaddr.c
> +++ b/mm/damon/vaddr.c
[ ... ]
> @@ -545,10 +544,8 @@ static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr,
> goto huge_out;
> if (pmd_young(*pmd) || !page_is_idle(page) ||
> mmu_notifier_test_young(walk->mm,
[Severity: High]
This is a pre-existing issue, but does the lockless PMD read earlier in
damon_young_pmd_entry() risk torn reads on architectures with non-atomic PMD
accesses?
In the THP check, the code performs a direct dereference:
if (pmd_huge(*pmd)) {
ptl = pmd_lock(walk->mm, pmd);
If a torn read occurs (e.g., on 32-bit architectures with 64-bit page table
entries like ARM LPAE or i386 PAE) while concurrent huge page operations like
THP collapse or split are happening, pmd_huge() might misidentify a huge PMD
as a regular PMD.
> - addr)) {
> - *priv->page_sz = ((1UL) << HPAGE_PMD_SHIFT);
> + addr))
> priv->young = true;
> - }
> put_page(page);
> huge_out:
> spin_unlock(ptl);
> @@ -567,10 +564,8 @@ static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr,
> if (!page)
> goto out;
> if (pte_young(*pte) || !page_is_idle(page) ||
[Severity: High]
This is also a pre-existing issue, but does the regular page fallback path
have the same torn read vulnerability?
Just before this block, the code directly dereferences the PMD again:
if (pmd_none(*pmd) || unlikely(pmd_bad(*pmd)))
return -EINVAL;
pte = pte_offset_map_lock(walk->mm, pmd, addr, &ptl);
If the execution falls through to pte_offset_map_lock() due to a torn
read misidentifying a huge PMD as regular, it would attempt to map the huge
page's physical memory as a page table. Dereferencing this could trigger
memory corruption or a machine check exception on non-existent memory.
Should these accesses be using pmdp_get_lockless() to ensure atomic reads?
> - mmu_notifier_test_young(walk->mm, addr)) {
> - *priv->page_sz = PAGE_SIZE;
> + mmu_notifier_test_young(walk->mm, addr))
> priv->young = true;
> - }
> put_page(page);
> out:
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260909060736.273661-1-sj@kernel.org?part=1
next prev parent reply other threads:[~2026-09-09 6:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <2026090859-trouble-fanatic-b990@gregkh>
2026-09-09 6:07 ` [PATCH 5.15.y] mm/damon/vaddr: drop last same folio access check optimization SJ Park
2026-09-09 6:17 ` sashiko-bot [this message]
2026-09-09 20:26 ` Sasha Levin
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=20260909061736.6830A1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=damon@lists.linux.dev \
--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.