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: <453c5296-fe6a-473f-8169-3cf2d3802691@os.amperecomputing.com>
Date: Tue, 4 Nov 2025 08:16:18 -0800
From: Yang Shi <yang@...amperecomputing.com>
To: Dev Jain <dev.jain@....com>, catalin.marinas@....com, will@...nel.org,
 ryan.roberts@....com
Cc: linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] arm64: kprobes: check the return value of
 set_memory_rox()



On 11/4/25 6:02 AM, Dev Jain wrote:
>
> On 04/11/25 1:15 am, Yang Shi wrote:
>> Since commit a166563e7ec3 ("arm64: mm: support large block mapping when
>> rodata=full"), __change_memory_common has more chance to fail due to
>> memory allocation fialure when splitting page table. So check the return
>> value of set_memory_rox(), then bail out if it fails otherwise we may 
>> have
>> RW memory mapping for kprobes insn page.
>>
>> Fixes: 195a1b7d8388 ("arm64: kprobes: call set_memory_rox() for 
>> kprobe page")
>> Signed-off-by: Yang Shi <yang@...amperecomputing.com>
>> ---
>> I actually epxected 195a1b7d8388 ("arm64: kprobes: call set_memory_rox()
>> for kprobe page") can be merged in 6.17-rcX, so I just restored it to
>> before commit 10d5e97c1bf8 ("arm64: use PAGE_KERNEL_ROX directly in
>> alloc_insn_page"), however it turned out to be merged in 6.18-rc1 and it
>> is after commit a166563e7ec3 ("arm64: mm: support large block mapping 
>> when
>> rodata=full"). So I made the fix tag point to it.
>> And I don't think we need to backport this patch to pre-6.18.
>>
>>   arch/arm64/kernel/probes/kprobes.c | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/kernel/probes/kprobes.c 
>> b/arch/arm64/kernel/probes/kprobes.c
>> index 8ab6104a4883..43a0361a8bf0 100644
>> --- a/arch/arm64/kernel/probes/kprobes.c
>> +++ b/arch/arm64/kernel/probes/kprobes.c
>> @@ -49,7 +49,10 @@ void *alloc_insn_page(void)
>>       addr = execmem_alloc(EXECMEM_KPROBES, PAGE_SIZE);
>>       if (!addr)
>>           return NULL;
>> -    set_memory_rox((unsigned long)addr, 1);
>> +    if (set_memory_rox((unsigned long)addr, 1)) {
>> +        execmem_free(addr);
>> +        return NULL;
>> +    }
>>       return addr;
>>   }
>
> Looks obviously correct:
>
> Reviewed-by: Dev Jain <dev.jain@....com>

Thank you.

>
> Although I got confused by why set_memory_rox() is being called; it is 
> being used
> only to handle the linear map alias perm change, which is not nice :) 
> but I don't
> see an obvious way to refactor the code to only perform the needed 
> functionality here,
> and probably this is not a hot path that we care about.

Catalin actually raised the similar suggestion before. He suggested 
extract the linear mapping update code into a helper then just call it 
here if I remember correctly. However I have not gotten time to look it 
deeper yet. Anyway we agree it is not a critical path. It may be not 
worth all the effort.

Thanks,
Yang


>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ