public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Ryan Roberts <ryan.roberts@arm.com>
To: Dev Jain <dev.jain@arm.com>, catalin.marinas@arm.com, will@kernel.org
Cc: anshuman.khandual@arm.com, quic_zhenhuah@quicinc.com,
	kevin.brodsky@arm.com, yangyicong@hisilicon.com,
	joey.gouly@arm.com, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, mark.rutland@arm.com,
	maz@kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] arm64/mm: Fix use-after-free due to race between memory hotunplug and ptdump
Date: Mon, 28 Jul 2025 12:13:51 +0100	[thread overview]
Message-ID: <f0e12d1e-110d-4a56-9f77-8fe2d664b0d1@arm.com> (raw)
In-Reply-To: <20250728103137.94726-1-dev.jain@arm.com>

On 28/07/2025 11:31, Dev Jain wrote:
> Memory hotunplug is done under the hotplug lock and ptdump walk is done
> under the init_mm.mmap_lock. Therefore, ptdump and hotunplug can run
> simultaneously without any synchronization. During hotunplug,
> free_empty_tables() is ultimately called to free up the pagetables.
> The following race can happen, where x denotes the level of the pagetable:
> 
> CPU1					CPU2
> free_empty_pxd_table
> 					ptdump_walk_pgd()
> 					Get p(x+1)d table from pxd entry
> pxd_clear
> free_hotplug_pgtable_page(p(x+1)dp)
> 					Still using the p(x+1)d table
> 
> which leads to a user-after-free.

I'm not sure I understand this. ptdump_show() protects against this with
get_online_mems()/put_online_mems(), doesn't it? There are 2 paths that call
ptdump_walk_pgd(). This protects one of them. The other is ptdump_check_wx(); I
thought you (or Anshuman?) had a patch in flight to fix that with
[get|put]_online_mems() too?

Sorry if my memory is failing me here...


  parent reply	other threads:[~2025-07-28 11:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-28 10:31 [PATCH] arm64/mm: Fix use-after-free due to race between memory hotunplug and ptdump Dev Jain
2025-07-28 10:42 ` Dev Jain
2025-07-28 11:13 ` Ryan Roberts [this message]
2025-07-28 11:31   ` Dev Jain
2025-07-28 11:56     ` Ryan Roberts

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=f0e12d1e-110d-4a56-9f77-8fe2d664b0d1@arm.com \
    --to=ryan.roberts@arm.com \
    --cc=anshuman.khandual@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=dev.jain@arm.com \
    --cc=joey.gouly@arm.com \
    --cc=kevin.brodsky@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=quic_zhenhuah@quicinc.com \
    --cc=stable@vger.kernel.org \
    --cc=will@kernel.org \
    --cc=yangyicong@hisilicon.com \
    /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