* [PATCH] arm64: mm: reset address tag set by kasan sw tagging
@ 2020-06-10 11:09 Shyam Thombre
2020-06-10 11:36 ` Catalin Marinas
2020-06-15 16:34 ` Will Deacon
0 siblings, 2 replies; 4+ messages in thread
From: Shyam Thombre @ 2020-06-10 11:09 UTC (permalink / raw)
To: catalin.marinas, will.deacon, ard.biesheuvel, mark.rutland,
anshuman.khandual, sashal
Cc: linux-arm-kernel, linux-kernel, Shyam Thombre
KASAN sw tagging sets a random tag of 8 bits in the top byte of the pointer
returned by the memory allocating functions. So for the functions unaware
of this change, the top 8 bits of the address must be reset which is done
by the function arch_kasan_reset_tag().
Signed-off-by: Shyam Thombre <sthombre@codeaurora.org>
---
arch/arm64/mm/mmu.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index e7fbc62..eae7655 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -723,6 +723,7 @@ int kern_addr_valid(unsigned long addr)
pmd_t *pmdp, pmd;
pte_t *ptep, pte;
+ addr = arch_kasan_reset_tag(addr);
if ((((long)addr) >> VA_BITS) != -1UL)
return 0;
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64: mm: reset address tag set by kasan sw tagging
2020-06-10 11:09 [PATCH] arm64: mm: reset address tag set by kasan sw tagging Shyam Thombre
@ 2020-06-10 11:36 ` Catalin Marinas
2020-06-12 13:57 ` Shyam Thombre
2020-06-15 16:34 ` Will Deacon
1 sibling, 1 reply; 4+ messages in thread
From: Catalin Marinas @ 2020-06-10 11:36 UTC (permalink / raw)
To: Shyam Thombre
Cc: will.deacon, ard.biesheuvel, mark.rutland, anshuman.khandual,
sashal, linux-arm-kernel, linux-kernel
On Wed, Jun 10, 2020 at 04:39:44PM +0530, Shyam Thombre wrote:
> KASAN sw tagging sets a random tag of 8 bits in the top byte of the pointer
> returned by the memory allocating functions. So for the functions unaware
> of this change, the top 8 bits of the address must be reset which is done
> by the function arch_kasan_reset_tag().
>
> Signed-off-by: Shyam Thombre <sthombre@codeaurora.org>
> ---
> arch/arm64/mm/mmu.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index e7fbc62..eae7655 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -723,6 +723,7 @@ int kern_addr_valid(unsigned long addr)
> pmd_t *pmdp, pmd;
> pte_t *ptep, pte;
>
> + addr = arch_kasan_reset_tag(addr);
> if ((((long)addr) >> VA_BITS) != -1UL)
> return 0;
It would be interesting to know what fails without this patch. The only
user seems to be read_kcore() and, at a quick look, I don't see how it
can generate tagged addresses.
--
Catalin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64: mm: reset address tag set by kasan sw tagging
2020-06-10 11:36 ` Catalin Marinas
@ 2020-06-12 13:57 ` Shyam Thombre
0 siblings, 0 replies; 4+ messages in thread
From: Shyam Thombre @ 2020-06-12 13:57 UTC (permalink / raw)
To: Catalin Marinas
Cc: will.deacon, ard.biesheuvel, mark.rutland, anshuman.khandual,
sashal, linux-arm-kernel, linux-kernel, jcrouse
Hi Catalin,
On 6/10/2020 5:06 PM, Catalin Marinas wrote:
> On Wed, Jun 10, 2020 at 04:39:44PM +0530, Shyam Thombre wrote:
>> KASAN sw tagging sets a random tag of 8 bits in the top byte of the pointer
>> returned by the memory allocating functions. So for the functions unaware
>> of this change, the top 8 bits of the address must be reset which is done
>> by the function arch_kasan_reset_tag().
>>
>> Signed-off-by: Shyam Thombre <sthombre@codeaurora.org>
>> ---
>> arch/arm64/mm/mmu.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
>> index e7fbc62..eae7655 100644
>> --- a/arch/arm64/mm/mmu.c
>> +++ b/arch/arm64/mm/mmu.c
>> @@ -723,6 +723,7 @@ int kern_addr_valid(unsigned long addr)
>> pmd_t *pmdp, pmd;
>> pte_t *ptep, pte;
>>
>> + addr = arch_kasan_reset_tag(addr);
>> if ((((long)addr) >> VA_BITS) != -1UL)
>> return 0;
>
> It would be interesting to know what fails without this patch. The only
> user seems to be read_kcore() and, at a quick look, I don't see how it
> can generate tagged addresses.
>
This issue is seen in downstream GPU drivers. It currently doesn't look
to impact any upstream users.
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arm64: mm: reset address tag set by kasan sw tagging
2020-06-10 11:09 [PATCH] arm64: mm: reset address tag set by kasan sw tagging Shyam Thombre
2020-06-10 11:36 ` Catalin Marinas
@ 2020-06-15 16:34 ` Will Deacon
1 sibling, 0 replies; 4+ messages in thread
From: Will Deacon @ 2020-06-15 16:34 UTC (permalink / raw)
To: mark.rutland, anshuman.khandual, sashal, catalin.marinas,
ard.biesheuvel, Shyam Thombre, will.deacon
Cc: Will Deacon, linux-kernel, linux-arm-kernel
On Wed, 10 Jun 2020 16:39:44 +0530, Shyam Thombre wrote:
> KASAN sw tagging sets a random tag of 8 bits in the top byte of the pointer
> returned by the memory allocating functions. So for the functions unaware
> of this change, the top 8 bits of the address must be reset which is done
> by the function arch_kasan_reset_tag().
Applied to arm64 (for-next/fixes), thanks!
[1/1] arm64: mm: reset address tag set by kasan sw tagging
https://git.kernel.org/arm64/c/8dd4daa04278
Cheers,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-06-15 16:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-10 11:09 [PATCH] arm64: mm: reset address tag set by kasan sw tagging Shyam Thombre
2020-06-10 11:36 ` Catalin Marinas
2020-06-12 13:57 ` Shyam Thombre
2020-06-15 16:34 ` Will Deacon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).