lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ad29f800-34e3-45c4-afd6-3661b9cfaec3@arm.com>
Date: Mon, 28 Jul 2025 12:56:44 +0100
From: Ryan Roberts <ryan.roberts@....com>
To: Dev Jain <dev.jain@....com>, catalin.marinas@....com, will@...nel.org
Cc: anshuman.khandual@....com, quic_zhenhuah@...cinc.com,
 kevin.brodsky@....com, yangyicong@...ilicon.com, joey.gouly@....com,
 linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
 mark.rutland@....com, maz@...nel.org, stable@...r.kernel.org
Subject: Re: [PATCH] arm64/mm: Fix use-after-free due to race between memory
 hotunplug and ptdump

On 28/07/2025 12:31, Dev Jain wrote:
> 
> On 28/07/25 4:43 pm, Ryan Roberts wrote:
>> 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...
> 
> Nope, I think I just had a use-after-free in my memory so I came up with this
> patch :)
> Because of the recent work with ptdump, I was so concentrated on
> ptdump_walk_pgd() that I
> didn't even bother looking up the call chain. And I even forgot we had these
> [get|put]_online_mems()
> patches recently.

I just checked; Anshuman's fix is in mm-stable, so I guess it'll be in v6.17-rc1.

That's the patch:
https://lore.kernel.org/linux-arm-kernel/20250620052427.2092093-1-anshuman.khandual@arm.com/

> 
> Sorry for the noise, it must have been incredibly confusing to see this patch :(
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ