[PATCH] powerpc/32: Fix protection of kernel RAM after freeing unused memory
Christophe LEROY
christophe.leroy at c-s.fr
Tue Apr 18 18:15:16 AEST 2017
Le 18/04/2017 à 08:40, Michael Ellerman a écrit :
> Christophe Leroy <christophe.leroy at c-s.fr> writes:
>
>
>> diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
>> index a65c0b4c0669..d506bd61b629 100644
>> --- a/arch/powerpc/mm/pgtable_32.c
>> +++ b/arch/powerpc/mm/pgtable_32.c
>> @@ -323,6 +323,26 @@ get_pteptr(struct mm_struct *mm, unsigned long addr, pte_t **ptep, pmd_t **pmdp)
>> return(retval);
>> }
>>
>> +void remap_init_ram(void)
>> +{
>> + unsigned long start = (unsigned long)_sinittext & PAGE_MASK;
>> + unsigned long end = (unsigned long)_einittext;
>> + unsigned long va;
>> +
>> + for (va = start; va < end; va += PAGE_SIZE) {
>> + pte_t *kpte;
>> + pmd_t *kpmd;
>> + pte_t pte = pfn_pte(__pa(va) >> PAGE_SHIFT, PAGE_KERNEL);
>> +
>> + if (!get_pteptr(&init_mm, va, &kpte, &kpmd))
>> + continue;
>> + __set_pte_at(&init_mm, va, kpte, pte, 0);
>> + wmb();
>> + pte_unmap(kpte);
>> + }
>> + flush_tlb_kernel_range(start, end);
>> +}
>
> Can we just use unmap_kernel_range() ?
We only want to remove the X bit.
I think unmap_kernel_range() will unmap the area, wheareas we want to
keep it as part of the linear data area.
Christophe
>
> Is this sufficient on all 32-bit PPC? (I have no idea)
>
> cheers
>
More information about the Linuxppc-dev
mailing list